Files
2022-01-20 20:30:18 +01:00

2.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5a23c84252665b21eecc7eb0 I before E except after C 5 302288 i-before-e-except-after-c

--description--

["I before E, except after C"](https://en.wikipedia.org/wiki/I before E except after C) は広く知られているニーモニック (覚え歌) で、英単語を綴る場合に役立つものです。

与えられた単語を使用して、フレーズの2つの従属節がそれぞれ妥当かどうかを確認します。

  1. 「I before E when not before preceded by C」
  2. 「E before I when preceded by C」

両方の従属節が妥当である場合は、元のフレーズは妥当であると言うことができます。

--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;
}