mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-13 06:04:13 -04:00
2.2 KiB
2.2 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 5a23c84252665b21eecc7eb0 | I 在 E 之前,除了 C 之后 | 1 | 302288 | i-before-e-except-after-c |
--description--
"I before E, except after C" is a general rule for English language spelling. If one is unsure whether a word is spelled with the digraph ei or ie, the rhyme suggests that the correct order is ie unless the preceding letter is c, in which case it may be ei.
使用所提供的词语,检查该短语的两个子条款是否分别合理:
- "I before E when not preceded by C".
- "前面是C,E在I前"
如果两个子短语都是合理的,则原始短语可以说是合理的。
--instructions--
编写一个接受单词的函数,并检查单词是否遵循此规则。 如果接收到的词遵循规则,则该函数应返回true,否则返回false。
--hints--
IBeforeExceptC 应该是一个函数。
assert(typeof IBeforeExceptC == 'function');
IBeforeExceptC("receive") 应该返回一个布尔值。
assert(typeof IBeforeExceptC('receive') == 'boolean');
IBeforeExceptC("receive") 应该返回 true。
assert.equal(IBeforeExceptC('receive'), true);
IBeforeExceptC("science") 应该返回 false。
assert.equal(IBeforeExceptC('science'), false);
IBeforeExceptC("imperceivable") 应该返回 true。
assert.equal(IBeforeExceptC('imperceivable'), true);
IBeforeExceptC("inconceivable") 应该返回 true。
assert.equal(IBeforeExceptC('inconceivable'), true);
IBeforeExceptC("insufficient") 应该返回 false.
assert.equal(IBeforeExceptC('insufficient'), false);
IBeforeExceptC("omniscient") 应该返回 false.
assert.equal(IBeforeExceptC('omniscient'), false);
--seed--
--seed-contents--
function IBeforeExceptC(word) {
}
--solutions--
function IBeforeExceptC(word)
{
if(word.indexOf("c")==-1 && word.indexOf("ie")!=-1)
return true;
else if(word.indexOf("cei")!=-1)
return true;
return false;
}