2018-10-04 14:37:37 +01:00
---
title: I before E except after C
id: 5a23c84252665b21eecc7eb0
challengeType: 5
2019-08-05 09:17:33 -07:00
forumTopicId: 302288
2018-10-04 14:37:37 +01:00
---
## Description
< section id = 'description' >
2019-03-06 14:18:18 +09:00
The phrase < a href = "https://en.wikipedia.org/wiki/I before E except after C" target = "_blank" > "I before E, except after C"< / a > is a widely known mnemonic which is supposed to help when spelling English words.
2018-10-04 14:37:37 +01:00
Using the words provided, check if the two sub-clauses of the phrase are plausible individually:
2019-03-06 14:18:18 +09:00
< ol >
< li >
< i > "I before E when not preceded by C".< / i >
< / li >
< li >
< i > "E before I when preceded by C".< / i >
< / li >
< / ol >
2018-10-04 14:37:37 +01:00
If both sub-phrases are plausible then the original phrase can be said to be plausible.
< / section >
## Instructions
< section id = 'instructions' >
2019-03-06 14:18:18 +09:00
Write a function that accepts a word and check if the word follows this rule. The function should return true if the word follows the rule and false if it does not.
2018-10-04 14:37:37 +01:00
< / section >
## Tests
< section id = 'tests' >
```yml
tests:
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC</ code > should be a function.
2019-07-26 05:24:52 -07:00
testString: assert(typeof IBeforeExceptC=='function');
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("receive")</ code > should return a boolean.
2019-07-26 05:24:52 -07:00
testString: assert(typeof IBeforeExceptC("receive")=='boolean');
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("receive")</ code > should return < code > true</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("receive"),true);
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("science")</ code > should return < code > false</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("science"),false);
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("imperceivable")</ code > should return < code > true</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("imperceivable"),true);
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("inconceivable")</ code > should return < code > true</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("inconceivable"),true);
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("insufficient")</ code > should return < code > false</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("insufficient"),false);
2018-10-08 12:52:10 +01:00
- text: < code > IBeforeExceptC("omniscient")</ code > should return < code > false</ code > .
2019-07-26 05:24:52 -07:00
testString: assert.equal(IBeforeExceptC("omniscient"),false);
2018-10-04 14:37:37 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
2019-03-06 14:18:18 +09:00
function IBeforeExceptC(word) {
2020-09-15 09:57:40 -07:00
2018-10-04 14:37:37 +01:00
}
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2019-03-06 14:18:18 +09:00
function IBeforeExceptC(word)
2018-10-04 14:37:37 +01:00
{
if(word.indexOf("c")==-1 & & word.indexOf("ie")!=-1)
return true;
else if(word.indexOf("cei")!=-1)
return true;
return false;
}
```
< / section >