* fix: removed assert msg argument * fix: removed msgs surrounded by 2 single quotes * fix: removed missing 2 assert msg arguments * fix: remove msg surrounded by two single quotes * fix: removed unnecessary assert msg args * fix; remove msgs surrounded by double quotes * fix: removed unnecessary assert msg args * fix: remove unnecessary assert msg args * fix: removed unnecessary assert msg arg * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg arg * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg args * fix: removed unnecessary assert msg arg * fix: removed unnecessary assert msg args * fix: Restore expected values to assertions * fix: remove assertion message Co-authored-by: Vivek Agrawal <vivekmittalagrawal@gmail.com>
2.4 KiB
2.4 KiB
title, id, challengeType
title | id | challengeType |
---|---|---|
I before E except after C | 5a23c84252665b21eecc7eb0 | 5 |
Description
- "I before E when not preceded by C".
- "E before I when preceded by C".
Instructions
Tests
tests:
- text: <code>IBeforeExceptC</code> should be a function.
testString: assert(typeof IBeforeExceptC=='function');
- text: <code>IBeforeExceptC("receive")</code> should return a boolean.
testString: assert(typeof IBeforeExceptC("receive")=='boolean');
- text: <code>IBeforeExceptC("receive")</code> should return <code>true</code>.
testString: assert.equal(IBeforeExceptC("receive"),true);
- text: <code>IBeforeExceptC("science")</code> should return <code>false</code>.
testString: assert.equal(IBeforeExceptC("science"),false);
- text: <code>IBeforeExceptC("imperceivable")</code> should return <code>true</code>.
testString: assert.equal(IBeforeExceptC("imperceivable"),true);
- text: <code>IBeforeExceptC("inconceivable")</code> should return <code>true</code>.
testString: assert.equal(IBeforeExceptC("inconceivable"),true);
- text: <code>IBeforeExceptC("insufficient")</code> should return <code>false</code>.
testString: assert.equal(IBeforeExceptC("insufficient"),false);
- text: <code>IBeforeExceptC("omniscient")</code> should return <code>false</code>.
testString: assert.equal(IBeforeExceptC("omniscient"),false);
Challenge Seed
function IBeforeExceptC(word) {
// Good luck!
}
Solution
function IBeforeExceptC(word)
{
if(word.indexOf("c")==-1 && word.indexOf("ie")!=-1)
return true;
else if(word.indexOf("cei")!=-1)
return true;
return false;
}