2018-10-10 18:03:03 -04:00
|
|
|
|
---
|
|
|
|
|
id: aa7697ea2477d1316795783b
|
|
|
|
|
title: Pig Latin
|
|
|
|
|
isRequired: true
|
|
|
|
|
challengeType: 5
|
|
|
|
|
videoUrl: ''
|
|
|
|
|
localeTitle: 猪拉丁文
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Description
|
2020-06-30 01:51:26 -07:00
|
|
|
|
<section id="description">将提供的字符串翻译为pig latin。 <a href="http://en.wikipedia.org/wiki/Pig_Latin" target="_blank">Pig Latin</a>使用英语单词的第一个辅音(或辅音簇),将其移到单词的末尾并加上“ay”后缀。如果一个单词以元音开头,你只需添加“way”到最后。输入字符串保证全部为小写英文单词。如果卡住,请记得使用<a href="https://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck-coding/19514" target="_blank">Read-Search-Ask</a> 。尝试配对程序。编写自己的代码。 </section>
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
## Instructions
|
|
|
|
|
<section id="instructions">
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Tests
|
|
|
|
|
<section id='tests'>
|
|
|
|
|
|
|
|
|
|
```yml
|
|
|
|
|
tests:
|
|
|
|
|
- text: <code>translatePigLatin("california")</code>应该返回“aliforniacay”。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("california"), "aliforniacay");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>translatePigLatin("paragraphs")</code>应该返回“aragraphspay”。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("paragraphs"), "aragraphspay");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>translatePigLatin("glove")</code>应该返回“oveglay”。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("glove"), "oveglay");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>translatePigLatin("algorithm")</code>应返回“algorithmway”。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("algorithm"), "algorithmway");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: <code>translatePigLatin("eight")</code>应该返回“八通”。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("eight"), "eightway");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: 应该处理第一个元音出现在单词末尾的单词。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("schwartz"), "artzschway");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
- text: 应该处理没有元音的单词。
|
2020-02-18 01:40:55 +09:00
|
|
|
|
testString: assert.deepEqual(translatePigLatin("rhythm"), "rhythmay");
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Challenge Seed
|
|
|
|
|
<section id='challengeSeed'>
|
|
|
|
|
|
|
|
|
|
<div id='js-seed'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
function translatePigLatin(str) {
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
translatePigLatin("consonant");
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
## Solution
|
|
|
|
|
<section id='solution'>
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
// solution required
|
|
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
|
|
|
|
|
/section>
|