freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-an.../intermediate-algorithm-scri.../pig-latin.chinese.md

2.7 KiB
Raw Blame History

id title isRequired challengeType videoUrl localeTitle
aa7697ea2477d1316795783b Pig Latin true 5 猪拉丁文

Description

将提供的字符串翻译为pig latin。 Pig Latin使用英语单词的第一个辅音或辅音簇将其移到单词的末尾并加上“ay”后缀。如果一个单词以元音开头你只需添加“way”到最后。输入字符串保证全部为小写英文单词。如果卡住请记得使用Read-Search-Ask 。尝试配对程序。编写自己的代码。

Instructions

Tests

tests:
  - text: <code>translatePigLatin(&quot;california&quot;)</code>应该返回“aliforniacay”。
    testString: 'assert.deepEqual(translatePigLatin("california"), "aliforniacay", "<code>translatePigLatin("california")</code> should return "aliforniacay".");'
  - text: <code>translatePigLatin(&quot;paragraphs&quot;)</code>应该返回“aragraphspay”。
    testString: 'assert.deepEqual(translatePigLatin("paragraphs"), "aragraphspay", "<code>translatePigLatin("paragraphs")</code> should return "aragraphspay".");'
  - text: <code>translatePigLatin(&quot;glove&quot;)</code>应该返回“oveglay”。
    testString: 'assert.deepEqual(translatePigLatin("glove"), "oveglay", "<code>translatePigLatin("glove")</code> should return "oveglay".");'
  - text: <code>translatePigLatin(&quot;algorithm&quot;)</code>应返回“algorithmway”。
    testString: 'assert.deepEqual(translatePigLatin("algorithm"), "algorithmway", "<code>translatePigLatin("algorithm")</code> should return "algorithmway".");'
  - text: <code>translatePigLatin(&quot;eight&quot;)</code>应该返回“八通”。
    testString: 'assert.deepEqual(translatePigLatin("eight"), "eightway", "<code>translatePigLatin("eight")</code> should return "eightway".");'
  - text: 应该处理第一个元音出现在单词末尾的单词。
    testString: 'assert.deepEqual(translatePigLatin("schwartz"), "artzschway", "Should handle words where the first vowel comes in the end of the word.");'
  - text: 应该处理没有元音的单词。
    testString: 'assert.deepEqual(translatePigLatin("rhythm"), "rhythmay", "Should handle words without vowels.");'

Challenge Seed

function translatePigLatin(str) {
  return str;
}

translatePigLatin("consonant");

Solution

// solution required