fix(challenge-md): Fix quotes that failed in the transform
This commit is contained in:
committed by
mrugesh mohapatra
parent
392b28fa55
commit
a859035023
@@ -23,25 +23,25 @@ Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>booWho(true)</code> should return true.
|
||||
testString: 'assert.strictEqual(booWho(true), true, ''<code>booWho(true)</code> should return true.'');'
|
||||
testString: 'assert.strictEqual(booWho(true), true, "<code>booWho(true)</code> should return true.");'
|
||||
- text: <code>booWho(false)</code> should return true.
|
||||
testString: 'assert.strictEqual(booWho(false), true, ''<code>booWho(false)</code> should return true.'');'
|
||||
testString: 'assert.strictEqual(booWho(false), true, "<code>booWho(false)</code> should return true.");'
|
||||
- text: '<code>booWho([1, 2, 3])</code> should return false.'
|
||||
testString: 'assert.strictEqual(booWho([1, 2, 3]), false, ''<code>booWho([1, 2, 3])</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho([1, 2, 3]), false, "<code>booWho([1, 2, 3])</code> should return false.");'
|
||||
- text: '<code>booWho([].slice)</code> should return false.'
|
||||
testString: 'assert.strictEqual(booWho([].slice), false, ''<code>booWho([].slice)</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho([].slice), false, "<code>booWho([].slice)</code> should return false.");'
|
||||
- text: '<code>booWho({ "a": 1 })</code> should return false.'
|
||||
testString: 'assert.strictEqual(booWho({ "a": 1 }), false, ''<code>booWho({ "a": 1 })</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho({ "a": 1 }), false, "<code>booWho({ "a": 1 })</code> should return false.");'
|
||||
- text: <code>booWho(1)</code> should return false.
|
||||
testString: 'assert.strictEqual(booWho(1), false, ''<code>booWho(1)</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho(1), false, "<code>booWho(1)</code> should return false.");'
|
||||
- text: <code>booWho(NaN)</code> should return false.
|
||||
testString: 'assert.strictEqual(booWho(NaN), false, ''<code>booWho(NaN)</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho(NaN), false, "<code>booWho(NaN)</code> should return false.");'
|
||||
- text: <code>booWho("a")</code> should return false.
|
||||
testString: 'assert.strictEqual(booWho("a"), false, ''<code>booWho("a")</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho("a"), false, "<code>booWho("a")</code> should return false.");'
|
||||
- text: <code>booWho("true")</code> should return false.
|
||||
testString: 'assert.strictEqual(booWho("true"), false, ''<code>booWho("true")</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho("true"), false, "<code>booWho("true")</code> should return false.");'
|
||||
- text: <code>booWho("false")</code> should return false.
|
||||
testString: 'assert.strictEqual(booWho("false"), false, ''<code>booWho("false")</code> should return false.'');'
|
||||
testString: 'assert.strictEqual(booWho("false"), false, "<code>booWho("false")</code> should return false.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,19 +22,19 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>chunkArrayInGroups(["a", "b", "c", "d"], 2)</code> should return <code>[["a", "b"], ["c", "d"]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups(["a", "b", "c", "d"], 2), [["a", "b"], ["c", "d"]], ''<code>chunkArrayInGroups(["a", "b", "c", "d"], 2)</code> should return <code>[["a", "b"], ["c", "d"]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups(["a", "b", "c", "d"], 2), [["a", "b"], ["c", "d"]], "<code>chunkArrayInGroups(["a", "b", "c", "d"], 2)</code> should return <code>[["a", "b"], ["c", "d"]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.");'
|
||||
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code>.'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], ''<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code>.'');'
|
||||
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,27 +23,27 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>confirmEnding("Bastian", "n")</code> should return true.'
|
||||
testString: 'assert(confirmEnding("Bastian", "n") === true, ''<code>confirmEnding("Bastian", "n")</code> should return true.'');'
|
||||
testString: 'assert(confirmEnding("Bastian", "n") === true, "<code>confirmEnding("Bastian", "n")</code> should return true.");'
|
||||
- text: '<code>confirmEnding("Congratulation", "on")</code> should return true.'
|
||||
testString: 'assert(confirmEnding("Congratulation", "on") === true, ''<code>confirmEnding("Congratulation", "on")</code> should return true.'');'
|
||||
testString: 'assert(confirmEnding("Congratulation", "on") === true, "<code>confirmEnding("Congratulation", "on")</code> should return true.");'
|
||||
- text: '<code>confirmEnding("Connor", "n")</code> should return false.'
|
||||
testString: 'assert(confirmEnding("Connor", "n") === false, ''<code>confirmEnding("Connor", "n")</code> should return false.'');'
|
||||
testString: 'assert(confirmEnding("Connor", "n") === false, "<code>confirmEnding("Connor", "n")</code> should return false.");'
|
||||
- text: '<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.'
|
||||
testString: 'assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false, ''<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.'');'
|
||||
testString: 'assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false, "<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.");'
|
||||
- text: '<code>confirmEnding("He has to give me a new name", "name")</code> should return true.'
|
||||
testString: 'assert(confirmEnding("He has to give me a new name", "name") === true, ''<code>confirmEnding("He has to give me a new name", "name")</code> should return true.'');'
|
||||
testString: 'assert(confirmEnding("He has to give me a new name", "name") === true, "<code>confirmEnding("He has to give me a new name", "name")</code> should return true.");'
|
||||
- text: '<code>confirmEnding("Open sesame", "same")</code> should return true.'
|
||||
testString: 'assert(confirmEnding("Open sesame", "same") === true, ''<code>confirmEnding("Open sesame", "same")</code> should return true.'');'
|
||||
testString: 'assert(confirmEnding("Open sesame", "same") === true, "<code>confirmEnding("Open sesame", "same")</code> should return true.");'
|
||||
- text: '<code>confirmEnding("Open sesame", "pen")</code> should return false.'
|
||||
testString: 'assert(confirmEnding("Open sesame", "pen") === false, ''<code>confirmEnding("Open sesame", "pen")</code> should return false.'');'
|
||||
testString: 'assert(confirmEnding("Open sesame", "pen") === false, "<code>confirmEnding("Open sesame", "pen")</code> should return false.");'
|
||||
- text: '<code>confirmEnding("Open sesame", "game")</code> should return false.'
|
||||
testString: 'assert(confirmEnding("Open sesame", "game") === false, ''<code>confirmEnding("Open sesame", "game")</code> should return false.'');'
|
||||
testString: 'assert(confirmEnding("Open sesame", "game") === false, "<code>confirmEnding("Open sesame", "game")</code> should return false.");'
|
||||
- text: '<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.'
|
||||
testString: 'assert(confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") === false, ''<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.'');'
|
||||
testString: 'assert(confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") === false, "<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.");'
|
||||
- text: '<code>confirmEnding("Abstraction", "action")</code> should return true.'
|
||||
testString: 'assert(confirmEnding("Abstraction", "action") === true, ''<code>confirmEnding("Abstraction", "action")</code> should return true.'');'
|
||||
testString: 'assert(confirmEnding("Abstraction", "action") === true, "<code>confirmEnding("Abstraction", "action")</code> should return true.");'
|
||||
- text: Do not use the built-in method <code>.endsWith()</code> to solve the challenge.
|
||||
testString: 'assert(!(/\.endsWith\(.*?\)\s*?;?/.test(code)) && !(/\[''endsWith''\]/.test(code)), ''Do not use the built-in method <code>.endsWith()</code> to solve the challenge.'');'
|
||||
testString: 'assert(!(/\.endsWith\(.*?\)\s*?;?/.test(code)) && !(/\["endsWith"\]/.test(code)), "Do not use the built-in method <code>.endsWith()</code> to solve the challenge.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,17 +23,17 @@ Don't worry too much about the function and return statements as they will be co
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>convertToF(0)</code> should return a number
|
||||
testString: 'assert(typeof convertToF(0) === ''number'', ''<code>convertToF(0)</code> should return a number'');'
|
||||
testString: 'assert(typeof convertToF(0) === "number", "<code>convertToF(0)</code> should return a number");'
|
||||
- text: <code>convertToF(-30)</code> should return a value of <code>-22</code>
|
||||
testString: 'assert(convertToF(-30) === -22, ''<code>convertToF(-30)</code> should return a value of <code>-22</code>'');'
|
||||
testString: 'assert(convertToF(-30) === -22, "<code>convertToF(-30)</code> should return a value of <code>-22</code>");'
|
||||
- text: <code>convertToF(-10)</code> should return a value of <code>14</code>
|
||||
testString: 'assert(convertToF(-10) === 14, ''<code>convertToF(-10)</code> should return a value of <code>14</code>'');'
|
||||
testString: 'assert(convertToF(-10) === 14, "<code>convertToF(-10)</code> should return a value of <code>14</code>");'
|
||||
- text: <code>convertToF(0)</code> should return a value of <code>32</code>
|
||||
testString: 'assert(convertToF(0) === 32, ''<code>convertToF(0)</code> should return a value of <code>32</code>'');'
|
||||
testString: 'assert(convertToF(0) === 32, "<code>convertToF(0)</code> should return a value of <code>32</code>");'
|
||||
- text: <code>convertToF(20)</code> should return a value of <code>68</code>
|
||||
testString: 'assert(convertToF(20) === 68, ''<code>convertToF(20)</code> should return a value of <code>68</code>'');'
|
||||
testString: 'assert(convertToF(20) === 68, "<code>convertToF(20)</code> should return a value of <code>68</code>");'
|
||||
- text: <code>convertToF(30)</code> should return a value of <code>86</code>
|
||||
testString: 'assert(convertToF(30) === 86, ''<code>convertToF(30)</code> should return a value of <code>86</code>'');'
|
||||
testString: 'assert(convertToF(30) === 86, "<code>convertToF(30)</code> should return a value of <code>86</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -26,15 +26,15 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>factorialize(5)</code> should return a number.
|
||||
testString: 'assert(typeof factorialize(5) === ''number'', ''<code>factorialize(5)</code> should return a number.'');'
|
||||
testString: 'assert(typeof factorialize(5) === "number", "<code>factorialize(5)</code> should return a number.");'
|
||||
- text: <code>factorialize(5)</code> should return 120.
|
||||
testString: 'assert(factorialize(5) === 120, ''<code>factorialize(5)</code> should return 120.'');'
|
||||
testString: 'assert(factorialize(5) === 120, "<code>factorialize(5)</code> should return 120.");'
|
||||
- text: <code>factorialize(10)</code> should return 3628800.
|
||||
testString: 'assert(factorialize(10) === 3628800, ''<code>factorialize(10)</code> should return 3628800.'');'
|
||||
testString: 'assert(factorialize(10) === 3628800, "<code>factorialize(10)</code> should return 3628800.");'
|
||||
- text: <code>factorialize(20)</code> should return 2432902008176640000.
|
||||
testString: 'assert(factorialize(20) === 2432902008176640000, ''<code>factorialize(20)</code> should return 2432902008176640000.'');'
|
||||
testString: 'assert(factorialize(20) === 2432902008176640000, "<code>factorialize(20)</code> should return 2432902008176640000.");'
|
||||
- text: <code>factorialize(0)</code> should return 1.
|
||||
testString: 'assert(factorialize(0) === 1, ''<code>factorialize(0)</code> should return 1.'');'
|
||||
testString: 'assert(factorialize(0) === 1, "<code>factorialize(0)</code> should return 1.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,13 +24,13 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>bouncer([7, "ate", "", false, 9])</code> should return <code>[7, "ate", 9]</code>.'
|
||||
testString: 'assert.deepEqual(bouncer([7, "ate", "", false, 9]), [7, "ate", 9], ''<code>bouncer([7, "ate", "", false, 9])</code> should return <code>[7, "ate", 9]</code>.'');'
|
||||
testString: 'assert.deepEqual(bouncer([7, "ate", "", false, 9]), [7, "ate", 9], "<code>bouncer([7, "ate", "", false, 9])</code> should return <code>[7, "ate", 9]</code>.");'
|
||||
- text: '<code>bouncer(["a", "b", "c"])</code> should return <code>["a", "b", "c"]</code>.'
|
||||
testString: 'assert.deepEqual(bouncer(["a", "b", "c"]), ["a", "b", "c"], ''<code>bouncer(["a", "b", "c"])</code> should return <code>["a", "b", "c"]</code>.'');'
|
||||
testString: 'assert.deepEqual(bouncer(["a", "b", "c"]), ["a", "b", "c"], "<code>bouncer(["a", "b", "c"])</code> should return <code>["a", "b", "c"]</code>.");'
|
||||
- text: '<code>bouncer([false, null, 0, NaN, undefined, ""])</code> should return <code>[]</code>.'
|
||||
testString: 'assert.deepEqual(bouncer([false, null, 0, NaN, undefined, ""]), [], ''<code>bouncer([false, null, 0, NaN, undefined, ""])</code> should return <code>[]</code>.'');'
|
||||
testString: 'assert.deepEqual(bouncer([false, null, 0, NaN, undefined, ""]), [], "<code>bouncer([false, null, 0, NaN, undefined, ""])</code> should return <code>[]</code>.");'
|
||||
- text: '<code>bouncer([1, null, NaN, 2, undefined])</code> should return <code>[1, 2]</code>.'
|
||||
testString: 'assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], ''<code>bouncer([1, null, NaN, 2, undefined])</code> should return <code>[1, 2]</code>.'');'
|
||||
testString: 'assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], "<code>bouncer([1, null, NaN, 2, undefined])</code> should return <code>[1, 2]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,17 +23,17 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return a number.
|
||||
testString: 'assert(typeof findLongestWordLength("The quick brown fox jumped over the lazy dog") === "number", ''<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return a number.'');'
|
||||
testString: 'assert(typeof findLongestWordLength("The quick brown fox jumped over the lazy dog") === "number", "<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return a number.");'
|
||||
- text: <code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return 6.
|
||||
testString: 'assert(findLongestWordLength("The quick brown fox jumped over the lazy dog") === 6, ''<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return 6.'');'
|
||||
testString: 'assert(findLongestWordLength("The quick brown fox jumped over the lazy dog") === 6, "<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return 6.");'
|
||||
- text: <code>findLongestWordLength("May the force be with you")</code> should return 5.
|
||||
testString: 'assert(findLongestWordLength("May the force be with you") === 5, ''<code>findLongestWordLength("May the force be with you")</code> should return 5.'');'
|
||||
testString: 'assert(findLongestWordLength("May the force be with you") === 5, "<code>findLongestWordLength("May the force be with you")</code> should return 5.");'
|
||||
- text: <code>findLongestWordLength("Google do a barrel roll")</code> should return 6.
|
||||
testString: 'assert(findLongestWordLength("Google do a barrel roll") === 6, ''<code>findLongestWordLength("Google do a barrel roll")</code> should return 6.'');'
|
||||
testString: 'assert(findLongestWordLength("Google do a barrel roll") === 6, "<code>findLongestWordLength("Google do a barrel roll")</code> should return 6.");'
|
||||
- text: <code>findLongestWordLength("What is the average airspeed velocity of an unladen swallow")</code> should return 8.
|
||||
testString: 'assert(findLongestWordLength("What is the average airspeed velocity of an unladen swallow") === 8, ''<code>findLongestWordLength("What is the average airspeed velocity of an unladen swallow")</code> should return 8.'');'
|
||||
testString: 'assert(findLongestWordLength("What is the average airspeed velocity of an unladen swallow") === 8, "<code>findLongestWordLength("What is the average airspeed velocity of an unladen swallow")</code> should return 8.");'
|
||||
- text: <code>findLongestWordLength("What if we try a super-long word such as otorhinolaryngology")</code> should return 19.
|
||||
testString: 'assert(findLongestWordLength("What if we try a super-long word such as otorhinolaryngology") === 19, ''<code>findLongestWordLength("What if we try a super-long word such as otorhinolaryngology")</code> should return 19.'');'
|
||||
testString: 'assert(findLongestWordLength("What if we try a super-long word such as otorhinolaryngology") === 19, "<code>findLongestWordLength("What if we try a super-long word such as otorhinolaryngology")</code> should return 19.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,9 +22,9 @@ Remember to use <a href='http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> should return 8.'
|
||||
testString: 'assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, ''<code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> should return 8.'');'
|
||||
testString: 'assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, "<code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> should return 8.");'
|
||||
- text: '<code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> should return undefined.'
|
||||
testString: 'assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, ''<code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> should return undefined.'');'
|
||||
testString: 'assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, "<code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> should return undefined.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,23 +25,23 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>mutation(["hello", "hey"])</code> should return false.'
|
||||
testString: 'assert(mutation(["hello", "hey"]) === false, ''<code>mutation(["hello", "hey"])</code> should return false.'');'
|
||||
testString: 'assert(mutation(["hello", "hey"]) === false, "<code>mutation(["hello", "hey"])</code> should return false.");'
|
||||
- text: '<code>mutation(["hello", "Hello"])</code> should return true.'
|
||||
testString: 'assert(mutation(["hello", "Hello"]) === true, ''<code>mutation(["hello", "Hello"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["hello", "Hello"]) === true, "<code>mutation(["hello", "Hello"])</code> should return true.");'
|
||||
- text: '<code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.'
|
||||
testString: 'assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true, ''<code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true, "<code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.");'
|
||||
- text: '<code>mutation(["Mary", "Army"])</code> should return true.'
|
||||
testString: 'assert(mutation(["Mary", "Army"]) === true, ''<code>mutation(["Mary", "Army"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["Mary", "Army"]) === true, "<code>mutation(["Mary", "Army"])</code> should return true.");'
|
||||
- text: '<code>mutation(["Mary", "Aarmy"])</code> should return true.'
|
||||
testString: 'assert(mutation(["Mary", "Aarmy"]) === true, ''<code>mutation(["Mary", "Aarmy"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["Mary", "Aarmy"]) === true, "<code>mutation(["Mary", "Aarmy"])</code> should return true.");'
|
||||
- text: '<code>mutation(["Alien", "line"])</code> should return true.'
|
||||
testString: 'assert(mutation(["Alien", "line"]) === true, ''<code>mutation(["Alien", "line"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["Alien", "line"]) === true, "<code>mutation(["Alien", "line"])</code> should return true.");'
|
||||
- text: '<code>mutation(["floor", "for"])</code> should return true.'
|
||||
testString: 'assert(mutation(["floor", "for"]) === true, ''<code>mutation(["floor", "for"])</code> should return true.'');'
|
||||
testString: 'assert(mutation(["floor", "for"]) === true, "<code>mutation(["floor", "for"])</code> should return true.");'
|
||||
- text: '<code>mutation(["hello", "neo"])</code> should return false.'
|
||||
testString: 'assert(mutation(["hello", "neo"]) === false, ''<code>mutation(["hello", "neo"])</code> should return false.'');'
|
||||
testString: 'assert(mutation(["hello", "neo"]) === false, "<code>mutation(["hello", "neo"])</code> should return false.");'
|
||||
- text: '<code>mutation(["voodoo", "no"])</code> should return false.'
|
||||
testString: 'assert(mutation(["voodoo", "no"]) === false, ''<code>mutation(["voodoo", "no"])</code> should return false.'');'
|
||||
testString: 'assert(mutation(["voodoo", "no"]) === false, "<code>mutation(["voodoo", "no"])</code> should return false.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,19 +22,19 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>repeatStringNumTimes("*", 3)</code> should return <code>"***"</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("*", 3) === "***", ''<code>repeatStringNumTimes("*", 3)</code> should return <code>"***"</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("*", 3) === "***", "<code>repeatStringNumTimes("*", 3)</code> should return <code>"***"</code>.");'
|
||||
- text: '<code>repeatStringNumTimes("abc", 3)</code> should return <code>"abcabcabc"</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 3) === "abcabcabc", ''<code>repeatStringNumTimes("abc", 3)</code> should return <code>"abcabcabc"</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 3) === "abcabcabc", "<code>repeatStringNumTimes("abc", 3)</code> should return <code>"abcabcabc"</code>.");'
|
||||
- text: '<code>repeatStringNumTimes("abc", 4)</code> should return <code>"abcabcabcabc"</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc", ''<code>repeatStringNumTimes("abc", 4)</code> should return <code>"abcabcabcabc"</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc", "<code>repeatStringNumTimes("abc", 4)</code> should return <code>"abcabcabcabc"</code>.");'
|
||||
- text: '<code>repeatStringNumTimes("abc", 1)</code> should return <code>"abc"</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 1) === "abc", ''<code>repeatStringNumTimes("abc", 1)</code> should return <code>"abc"</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("abc", 1) === "abc", "<code>repeatStringNumTimes("abc", 1)</code> should return <code>"abc"</code>.");'
|
||||
- text: '<code>repeatStringNumTimes("*", 8)</code> should return <code>"********"</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("*", 8) === "********", ''<code>repeatStringNumTimes("*", 8)</code> should return <code>"********"</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("*", 8) === "********", "<code>repeatStringNumTimes("*", 8)</code> should return <code>"********"</code>.");'
|
||||
- text: '<code>repeatStringNumTimes("abc", -2)</code> should return <code>""</code>.'
|
||||
testString: 'assert(repeatStringNumTimes("abc", -2) === "", ''<code>repeatStringNumTimes("abc", -2)</code> should return <code>""</code>.'');'
|
||||
testString: 'assert(repeatStringNumTimes("abc", -2) === "", "<code>repeatStringNumTimes("abc", -2)</code> should return <code>""</code>.");'
|
||||
- text: The built-in <code>repeat()</code>-method should not be used
|
||||
testString: 'assert(!/\.repeat/g.test(code), ''The built-in <code>repeat()</code>-method should not be used'');'
|
||||
testString: 'assert(!/\.repeat/g.test(code), "The built-in <code>repeat()</code>-method should not be used");'
|
||||
|
||||
```
|
||||
|
||||
@@ -66,7 +66,7 @@ repeatStringNumTimes("abc", 3);
|
||||
|
||||
```js
|
||||
function repeatStringNumTimes(str, num) {
|
||||
if (num < 0) return '';
|
||||
if (num < 0) return ";
|
||||
return num === 1 ? str : str + repeatStringNumTimes(str, num-1);
|
||||
}
|
||||
|
||||
|
@@ -23,13 +23,13 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return an array.'
|
||||
testString: 'assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, ''<code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return an array.'');'
|
||||
testString: 'assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, "<code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return an array.");'
|
||||
- text: '<code>largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return <code>[27, 5, 39, 1001]</code>.'
|
||||
testString: 'assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], ''<code>largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return <code>[27, 5, 39, 1001]</code>.'');'
|
||||
testString: 'assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], "<code>largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return <code>[27, 5, 39, 1001]</code>.");'
|
||||
- text: '<code>largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])</code> should return <code>[9, 35, 97, 1000000]</code>.'
|
||||
testString: 'assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], ''<code>largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])</code> should return <code>[9, 35, 97, 1000000]</code>.'');'
|
||||
testString: 'assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], "<code>largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])</code> should return <code>[9, 35, 97, 1000000]</code>.");'
|
||||
- text: '<code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should return <code>[25, 48, 21, -3]</code>.'
|
||||
testString: 'assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], ''<code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should return <code>[25, 48, 21, -3]</code>.'');'
|
||||
testString: 'assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], "<code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should return <code>[25, 48, 21, -3]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,13 +24,13 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>reverseString("hello")</code> should return a string.
|
||||
testString: 'assert(typeof reverseString("hello") === "string", ''<code>reverseString("hello")</code> should return a string.'');'
|
||||
testString: 'assert(typeof reverseString("hello") === "string", "<code>reverseString("hello")</code> should return a string.");'
|
||||
- text: <code>reverseString("hello")</code> should become <code>"olleh"</code>.
|
||||
testString: 'assert(reverseString("hello") === "olleh", ''<code>reverseString("hello")</code> should become <code>"olleh"</code>.'');'
|
||||
testString: 'assert(reverseString("hello") === "olleh", "<code>reverseString("hello")</code> should become <code>"olleh"</code>.");'
|
||||
- text: <code>reverseString("Howdy")</code> should become <code>"ydwoH"</code>.
|
||||
testString: 'assert(reverseString("Howdy") === "ydwoH", ''<code>reverseString("Howdy")</code> should become <code>"ydwoH"</code>.'');'
|
||||
testString: 'assert(reverseString("Howdy") === "ydwoH", "<code>reverseString("Howdy")</code> should become <code>"ydwoH"</code>.");'
|
||||
- text: <code>reverseString("Greetings from Earth")</code> should return <code>"htraE morf sgniteerG"</code>.
|
||||
testString: 'assert(reverseString("Greetings from Earth") === "htraE morf sgniteerG", ''<code>reverseString("Greetings from Earth")</code> should return <code>"htraE morf sgniteerG"</code>.'');'
|
||||
testString: 'assert(reverseString("Greetings from Earth") === "htraE morf sgniteerG", "<code>reverseString("Greetings from Earth")</code> should return <code>"htraE morf sgniteerG"</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -26,17 +26,17 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>frankenSplice([1, 2, 3], [4, 5], 1)</code> should return <code>[4, 1, 2, 3, 5]</code>.'
|
||||
testString: 'assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], ''<code>frankenSplice([1, 2, 3], [4, 5], 1)</code> should return <code>[4, 1, 2, 3, 5]</code>.'');'
|
||||
testString: 'assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], "<code>frankenSplice([1, 2, 3], [4, 5], 1)</code> should return <code>[4, 1, 2, 3, 5]</code>.");'
|
||||
- text: '<code>frankenSplice([1, 2], ["a", "b"], 1)</code> should return <code>["a", 1, 2, "b"]</code>.'
|
||||
testString: 'assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ["a", 1, 2, "b"], ''<code>frankenSplice([1, 2], ["a", "b"], 1)</code> should return <code>["a", 1, 2, "b"]</code>.'');'
|
||||
testString: 'assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ["a", 1, 2, "b"], "<code>frankenSplice([1, 2], ["a", "b"], 1)</code> should return <code>["a", 1, 2, "b"]</code>.");'
|
||||
- text: '<code>frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)</code> should return <code>["head", "shoulders", "claw", "tentacle", "knees", "toes"]</code>.'
|
||||
testString: 'assert.deepEqual(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2), ["head", "shoulders", "claw", "tentacle", "knees", "toes"], ''<code>frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)</code> should return <code>["head", "shoulders", "claw", "tentacle", "knees", "toes"]</code>.'');'
|
||||
testString: 'assert.deepEqual(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2), ["head", "shoulders", "claw", "tentacle", "knees", "toes"], "<code>frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)</code> should return <code>["head", "shoulders", "claw", "tentacle", "knees", "toes"]</code>.");'
|
||||
- text: All elements from the first array should be added to the second array in their original order.
|
||||
testString: 'assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], ''All elements from the first array should be added to the second array in their original order.'');'
|
||||
testString: 'assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], "All elements from the first array should be added to the second array in their original order.");'
|
||||
- text: The first array should remain the same after the function runs.
|
||||
testString: 'assert(testArr1[0] === 1 && testArr1[1] === 2, ''The first array should remain the same after the function runs.'');'
|
||||
testString: 'assert(testArr1[0] === 1 && testArr1[1] === 2, "The first array should remain the same after the function runs.");'
|
||||
- text: The second array should remain the same after the function runs.
|
||||
testString: 'assert(testArr2[0] === "a" && testArr2[1] === "b", ''The second array should remain the same after the function runs.'');'
|
||||
testString: 'assert(testArr2[0] === "a" && testArr2[1] === "b", "The second array should remain the same after the function runs.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,13 +23,13 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>titleCase("I'm a little tea pot")</code> should return a string.'
|
||||
testString: 'assert(typeof titleCase("I''m a little tea pot") === "string", ''<code>titleCase("I'm a little tea pot")</code> should return a string.'');'
|
||||
testString: 'assert(typeof titleCase("I"m a little tea pot") === "string", "<code>titleCase("I'm a little tea pot")</code> should return a string.");'
|
||||
- text: '<code>titleCase("I'm a little tea pot")</code> should return <code>I'm A Little Tea Pot</code>.'
|
||||
testString: 'assert(titleCase("I''m a little tea pot") === "I''m A Little Tea Pot", ''<code>titleCase("I'm a little tea pot")</code> should return <code>I'm A Little Tea Pot</code>.'');'
|
||||
testString: 'assert(titleCase("I"m a little tea pot") === "I"m A Little Tea Pot", "<code>titleCase("I'm a little tea pot")</code> should return <code>I'm A Little Tea Pot</code>.");'
|
||||
- text: <code>titleCase("sHoRt AnD sToUt")</code> should return <code>Short And Stout</code>.
|
||||
testString: 'assert(titleCase("sHoRt AnD sToUt") === "Short And Stout", ''<code>titleCase("sHoRt AnD sToUt")</code> should return <code>Short And Stout</code>.'');'
|
||||
testString: 'assert(titleCase("sHoRt AnD sToUt") === "Short And Stout", "<code>titleCase("sHoRt AnD sToUt")</code> should return <code>Short And Stout</code>.");'
|
||||
- text: <code>titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")</code> should return <code>Here Is My Handle Here Is My Spout</code>.
|
||||
testString: 'assert(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") === "Here Is My Handle Here Is My Spout", ''<code>titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")</code> should return <code>Here Is My Handle Here Is My Spout</code>.'');'
|
||||
testString: 'assert(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") === "Here Is My Handle Here Is My Spout", "<code>titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")</code> should return <code>Here Is My Handle Here Is My Spout</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,17 +22,17 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>truncateString("A-tisket a-tasket A green and yellow basket", 8)</code> should return "A-tisket...".'
|
||||
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", 8) === "A-tisket...", ''<code>truncateString("A-tisket a-tasket A green and yellow basket", 8)</code> should return "A-tisket...".'');'
|
||||
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", 8) === "A-tisket...", "<code>truncateString("A-tisket a-tasket A green and yellow basket", 8)</code> should return "A-tisket...".");'
|
||||
- text: '<code>truncateString("Peter Piper picked a peck of pickled peppers", 11)</code> should return "Peter Piper...".'
|
||||
testString: 'assert(truncateString("Peter Piper picked a peck of pickled peppers", 11) === "Peter Piper...", ''<code>truncateString("Peter Piper picked a peck of pickled peppers", 11)</code> should return "Peter Piper...".'');'
|
||||
testString: 'assert(truncateString("Peter Piper picked a peck of pickled peppers", 11) === "Peter Piper...", "<code>truncateString("Peter Piper picked a peck of pickled peppers", 11)</code> should return "Peter Piper...".");'
|
||||
- text: '<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)</code> should return "A-tisket a-tasket A green and yellow basket".'
|
||||
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) === "A-tisket a-tasket A green and yellow basket", ''<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)</code> should return "A-tisket a-tasket A green and yellow basket".'');'
|
||||
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) === "A-tisket a-tasket A green and yellow basket", "<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)</code> should return "A-tisket a-tasket A green and yellow basket".");'
|
||||
- text: '<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)</code> should return "A-tisket a-tasket A green and yellow basket".'
|
||||
testString: 'assert(truncateString(''A-tisket a-tasket A green and yellow basket'', ''A-tisket a-tasket A green and yellow basket''.length + 2) === ''A-tisket a-tasket A green and yellow basket'', ''<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)</code> should return "A-tisket a-tasket A green and yellow basket".'');'
|
||||
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) === "A-tisket a-tasket A green and yellow basket", "<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)</code> should return "A-tisket a-tasket A green and yellow basket".");'
|
||||
- text: '<code>truncateString("A-", 1)</code> should return "A...".'
|
||||
testString: 'assert(truncateString("A-", 1) === "A...", ''<code>truncateString("A-", 1)</code> should return "A...".'');'
|
||||
testString: 'assert(truncateString("A-", 1) === "A...", "<code>truncateString("A-", 1)</code> should return "A...".");'
|
||||
- text: '<code>truncateString("Absolutely Longer", 2)</code> should return "Ab...".'
|
||||
testString: 'assert(truncateString("Absolutely Longer", 2) === "Ab...", ''<code>truncateString("Absolutely Longer", 2)</code> should return "Ab...".'');'
|
||||
testString: 'assert(truncateString("Absolutely Longer", 2) === "Ab...", "<code>truncateString("Absolutely Longer", 2)</code> should return "Ab...".");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,37 +24,37 @@ Remember to use <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-yo
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.'
|
||||
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, ''<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.'');'
|
||||
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, "<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.");'
|
||||
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === "number", ''<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === "number", "<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.'
|
||||
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, ''<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.'');'
|
||||
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, "<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.");'
|
||||
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === "number", ''<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === "number", "<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([40, 60], 50)</code> should return <code>1</code>.'
|
||||
testString: 'assert(getIndexToIns([40, 60], 50) === 1, ''<code>getIndexToIns([40, 60], 50)</code> should return <code>1</code>.'');'
|
||||
testString: 'assert(getIndexToIns([40, 60], 50) === 1, "<code>getIndexToIns([40, 60], 50)</code> should return <code>1</code>.");'
|
||||
- text: '<code>getIndexToIns([40, 60], 50)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([40, 60], 50)) === "number", ''<code>getIndexToIns([40, 60], 50)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([40, 60], 50)) === "number", "<code>getIndexToIns([40, 60], 50)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([3, 10, 5], 3)</code> should return <code>0</code>.'
|
||||
testString: 'assert(getIndexToIns([3, 10, 5], 3) === 0, ''<code>getIndexToIns([3, 10, 5], 3)</code> should return <code>0</code>.'');'
|
||||
testString: 'assert(getIndexToIns([3, 10, 5], 3) === 0, "<code>getIndexToIns([3, 10, 5], 3)</code> should return <code>0</code>.");'
|
||||
- text: '<code>getIndexToIns([3, 10, 5], 3)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([3, 10, 5], 3)) === "number", ''<code>getIndexToIns([3, 10, 5], 3)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([3, 10, 5], 3)) === "number", "<code>getIndexToIns([3, 10, 5], 3)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return <code>2</code>.'
|
||||
testString: 'assert(getIndexToIns([5, 3, 20, 3], 5) === 2, ''<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return <code>2</code>.'');'
|
||||
testString: 'assert(getIndexToIns([5, 3, 20, 3], 5) === 2, "<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return <code>2</code>.");'
|
||||
- text: '<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === "number", ''<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === "number", "<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([2, 20, 10], 19)</code> should return <code>2</code>.'
|
||||
testString: 'assert(getIndexToIns([2, 20, 10], 19) === 2, ''<code>getIndexToIns([2, 20, 10], 19)</code> should return <code>2</code>.'');'
|
||||
testString: 'assert(getIndexToIns([2, 20, 10], 19) === 2, "<code>getIndexToIns([2, 20, 10], 19)</code> should return <code>2</code>.");'
|
||||
- text: '<code>getIndexToIns([2, 20, 10], 19)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([2, 20, 10], 19)) === "number", ''<code>getIndexToIns([2, 20, 10], 19)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([2, 20, 10], 19)) === "number", "<code>getIndexToIns([2, 20, 10], 19)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([2, 5, 10], 15)</code> should return <code>3</code>.'
|
||||
testString: 'assert(getIndexToIns([2, 5, 10], 15) === 3, ''<code>getIndexToIns([2, 5, 10], 15)</code> should return <code>3</code>.'');'
|
||||
testString: 'assert(getIndexToIns([2, 5, 10], 15) === 3, "<code>getIndexToIns([2, 5, 10], 15)</code> should return <code>3</code>.");'
|
||||
- text: '<code>getIndexToIns([2, 5, 10], 15)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([2, 5, 10], 15)) === "number", ''<code>getIndexToIns([2, 5, 10], 15)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([2, 5, 10], 15)) === "number", "<code>getIndexToIns([2, 5, 10], 15)</code> should return a number.");'
|
||||
- text: '<code>getIndexToIns([], 1)</code> should return <code>0</code>.'
|
||||
testString: 'assert(getIndexToIns([], 1) === 0, ''<code>getIndexToIns([], 1)</code> should return <code>0</code>.'');'
|
||||
testString: 'assert(getIndexToIns([], 1) === 0, "<code>getIndexToIns([], 1)</code> should return <code>0</code>.");'
|
||||
- text: '<code>getIndexToIns([], 1)</code> should return a number.'
|
||||
testString: 'assert(typeof(getIndexToIns([], 1)) === "number", ''<code>getIndexToIns([], 1)</code> should return a number.'');'
|
||||
testString: 'assert(typeof(getIndexToIns([], 1)) === "number", "<code>getIndexToIns([], 1)</code> should return a number.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,9 +23,9 @@ We've defined a function, <code>countOnline</code>; use a <dfn>for...in</dfn> st
|
||||
```yml
|
||||
tests:
|
||||
- text: The <code>users</code> object contains users <code>Jeff</code> and <code>Ryan</code> with <code>online</code> set to <code>true</code> and users <code>Alan</code> and <code>Sarah</code> with <code>online</code> set to <code>false</code>
|
||||
testString: 'assert(users.Alan.online === false && users.Jeff.online === true && users.Sarah.online === false && users.Ryan.online === true, ''The <code>users</code> object contains users <code>Jeff</code> and <code>Ryan</code> with <code>online</code> set to <code>true</code> and users <code>Alan</code> and <code>Sarah</code> with <code>online</code> set to <code>false</code>'');'
|
||||
testString: 'assert(users.Alan.online === false && users.Jeff.online === true && users.Sarah.online === false && users.Ryan.online === true, "The <code>users</code> object contains users <code>Jeff</code> and <code>Ryan</code> with <code>online</code> set to <code>true</code> and users <code>Alan</code> and <code>Sarah</code> with <code>online</code> set to <code>false</code>");'
|
||||
- text: The function <code>countOnline</code> returns the number of users with the <code>online</code> property set to <code>true</code>
|
||||
testString: 'assert((function() { users.Harry = {online: true}; users.Sam = {online: true}; users.Carl = {online: true}; return countOnline(users) })() === 5, ''The function <code>countOnline</code> returns the number of users with the <code>online</code> property set to <code>true</code>'');'
|
||||
testString: 'assert((function() { users.Harry = {online: true}; users.Sam = {online: true}; users.Carl = {online: true}; return countOnline(users) })() === 5, "The function <code>countOnline</code> returns the number of users with the <code>online</code> property set to <code>true</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -29,13 +29,13 @@ In order to complete this challenge, set the 2nd position (index <code>1</code>)
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray[0]</code> is equal to <code>"a"</code>'
|
||||
testString: 'assert.strictEqual(myArray[0], "a", ''<code>myArray[0]</code> is equal to <code>"a"</code>'');'
|
||||
testString: 'assert.strictEqual(myArray[0], "a", "<code>myArray[0]</code> is equal to <code>"a"</code>");'
|
||||
- text: '<code>myArray[1]</code> is no longer set to <code>"b"</code>'
|
||||
testString: 'assert.notStrictEqual(myArray[1], "b", ''<code>myArray[1]</code> is no longer set to <code>"b"</code>'');'
|
||||
testString: 'assert.notStrictEqual(myArray[1], "b", "<code>myArray[1]</code> is no longer set to <code>"b"</code>");'
|
||||
- text: '<code>myArray[2]</code> is equal to <code>"c"</code>'
|
||||
testString: 'assert.strictEqual(myArray[2], "c", ''<code>myArray[2]</code> is equal to <code>"c"</code>'');'
|
||||
testString: 'assert.strictEqual(myArray[2], "c", "<code>myArray[2]</code> is equal to <code>"c"</code>");'
|
||||
- text: '<code>myArray[3]</code> is equal to <code>"d"</code>'
|
||||
testString: 'assert.strictEqual(myArray[3], "d", ''<code>myArray[3]</code> is equal to <code>"d"</code>'');'
|
||||
testString: 'assert.strictEqual(myArray[3], "d", "<code>myArray[3]</code> is equal to <code>"d"</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,15 +22,15 @@ We've defined a function, <code>checkInventory</code>, which receives a scanned
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>checkInventory</code> is a function
|
||||
testString: 'assert.strictEqual(typeof checkInventory, ''function'', ''<code>checkInventory</code> is a function'');'
|
||||
testString: 'assert.strictEqual(typeof checkInventory, "function", "<code>checkInventory</code> is a function");'
|
||||
- text: 'The <code>foods</code> object should have only the following key-value pairs: <code>apples: 25</code>, <code>oranges: 32</code>, <code>plums: 28</code>, <code>bananas: 13</code>, <code>grapes: 35</code>, <code>strawberries: 27</code>'
|
||||
testString: 'assert.deepEqual(foods, {apples: 25, oranges: 32, plums: 28, bananas: 13, grapes: 35, strawberries: 27}, ''The <code>foods</code> object should have only the following key-value pairs: <code>apples: 25</code>, <code>oranges: 32</code>, <code>plums: 28</code>, <code>bananas: 13</code>, <code>grapes: 35</code>, <code>strawberries: 27</code>'');'
|
||||
testString: 'assert.deepEqual(foods, {apples: 25, oranges: 32, plums: 28, bananas: 13, grapes: 35, strawberries: 27}, "The <code>foods</code> object should have only the following key-value pairs: <code>apples: 25</code>, <code>oranges: 32</code>, <code>plums: 28</code>, <code>bananas: 13</code>, <code>grapes: 35</code>, <code>strawberries: 27</code>");'
|
||||
- text: <code>checkInventory("apples")</code> should return <code>25</code>
|
||||
testString: 'assert.strictEqual(checkInventory(''apples''), 25, ''<code>checkInventory("apples")</code> should return <code>25</code>'');'
|
||||
testString: 'assert.strictEqual(checkInventory("apples"), 25, "<code>checkInventory("apples")</code> should return <code>25</code>");'
|
||||
- text: <code>checkInventory("bananas")</code> should return <code>13</code>
|
||||
testString: 'assert.strictEqual(checkInventory(''bananas''), 13, ''<code>checkInventory("bananas")</code> should return <code>13</code>'');'
|
||||
testString: 'assert.strictEqual(checkInventory("bananas"), 13, "<code>checkInventory("bananas")</code> should return <code>13</code>");'
|
||||
- text: <code>checkInventory("strawberries")</code> should return <code>27</code>
|
||||
testString: 'assert.strictEqual(checkInventory(''strawberries''), 27, ''<code>checkInventory("strawberries")</code> should return <code>27</code>'');'
|
||||
testString: 'assert.strictEqual(checkInventory("strawberries"), 27, "<code>checkInventory("strawberries")</code> should return <code>27</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -6,7 +6,7 @@ challengeType: 1
|
||||
|
||||
## Description
|
||||
<section id='description'>
|
||||
An array's length, like the data types it can contain, is not fixed. Arrays can be defined with a length of any number of elements, and elements can be added or removed over time; in other words, arrays are <dfn>mutable</dfn>. In this challenge, we will look at two methods with which we can programmatically modify an array: <code>Array.push()</code> and <code>Array.unshift()</code>.
|
||||
An array's length, like the data types it can contain, is not fixed. Arrays can be defined with a length of any number of elements, and elements can be added or removed over time; in other words, arrays are <dfn>mutable</dfn>. In this challenge, we will look at two methods with which we can programmatically modify an array: <code>Array.push()</code> and <code>Array.unshift()</code>.
|
||||
Both methods take one or more elements as parameters and add those elements to the array the method is being called on; the <code>push()</code> method adds elements to the end of an array, and <code>unshift()</code> adds elements to the beginning. Consider the following:
|
||||
<blockquote>let twentyThree = 'XXIII';<br>let romanNumerals = ['XXI', 'XXII'];<br><br>romanNumerals.unshift('XIX', 'XX');<br>// now equals ['XIX', 'XX', 'XXI', 'XXII']<br><br>romanNumerals.push(twentyThree);<br>// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']
|
||||
Notice that we can also pass variables, which allows us even greater flexibility in dynamically modifying our array's data.
|
||||
@@ -23,11 +23,11 @@ We have defined a function, <code>mixedNumbers</code>, which we are passing an a
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>mixedNumbers(["IV", 5, "six"])</code> should now return <code>["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]</code>'
|
||||
testString: 'assert.deepEqual(mixedNumbers([''IV'', 5, ''six'']), [''I'', 2, ''three'', ''IV'', 5, ''six'', 7, ''VIII'', 9], ''<code>mixedNumbers(["IV", 5, "six"])</code> should now return <code>["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]</code>'');'
|
||||
testString: 'assert.deepEqual(mixedNumbers(["IV", 5, "six"]), ["I", 2, "three", "IV", 5, "six", 7, "VIII", 9], "<code>mixedNumbers(["IV", 5, "six"])</code> should now return <code>["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]</code>");'
|
||||
- text: The <code>mixedNumbers</code> function should utilize the <code>push()</code> method
|
||||
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.push\(/), -1, ''The <code>mixedNumbers</code> function should utilize the <code>push()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.push\(/), -1, "The <code>mixedNumbers</code> function should utilize the <code>push()</code> method");'
|
||||
- text: The <code>mixedNumbers</code> function should utilize the <code>unshift()</code> method
|
||||
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.unshift\(/), -1, ''The <code>mixedNumbers</code> function should utilize the <code>unshift()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.unshift\(/), -1, "The <code>mixedNumbers</code> function should utilize the <code>unshift()</code> method");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,13 +22,13 @@ We have defined a function, <code>htmlColorNames</code>, which takes an array of
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>htmlColorNames</code> should return <code>["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"]</code>'
|
||||
testString: 'assert.deepEqual(htmlColorNames([''DarkGoldenRod'', ''WhiteSmoke'', ''LavenderBlush'', ''PaleTurqoise'', ''FireBrick'']), [''DarkSalmon'', ''BlanchedAlmond'', ''LavenderBlush'', ''PaleTurqoise'', ''FireBrick''], ''<code>htmlColorNames</code> should return <code>["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"]</code>'');'
|
||||
testString: 'assert.deepEqual(htmlColorNames(["DarkGoldenRod", "WhiteSmoke", "LavenderBlush", "PaleTurqoise", "FireBrick"]), ["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"], "<code>htmlColorNames</code> should return <code>["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"]</code>");'
|
||||
- text: The <code>htmlColorNames</code> function should utilize the <code>splice()</code> method
|
||||
testString: 'assert(/.splice/.test(code), ''The <code>htmlColorNames</code> function should utilize the <code>splice()</code> method'');'
|
||||
testString: 'assert(/.splice/.test(code), "The <code>htmlColorNames</code> function should utilize the <code>splice()</code> method");'
|
||||
- text: You should not use <code>shift()</code> or <code>unshift()</code>.
|
||||
testString: 'assert(!/shift|unshift/.test(code), ''You should not use <code>shift()</code> or <code>unshift()</code>.'');'
|
||||
testString: 'assert(!/shift|unshift/.test(code), "You should not use <code>shift()</code> or <code>unshift()</code>.");'
|
||||
- text: You should not use array bracket notation.
|
||||
testString: 'assert(!/\[\d\]\s*=/.test(code), ''You should not use array bracket notation.'');'
|
||||
testString: 'assert(!/\[\d\]\s*=/.test(code), "You should not use array bracket notation.");'
|
||||
|
||||
```
|
||||
|
||||
@@ -42,11 +42,11 @@ tests:
|
||||
```js
|
||||
function htmlColorNames(arr) {
|
||||
// change code below this line
|
||||
|
||||
|
||||
// change code above this line
|
||||
return arr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// do not change code below this line
|
||||
console.log(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurqoise', 'FireBrick']));
|
||||
```
|
||||
|
@@ -26,15 +26,15 @@ Using the same syntax, we can also <em><strong>add new</strong></em> key-value p
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>foods</code> is an object
|
||||
testString: 'assert(typeof foods === ''object'', ''<code>foods</code> is an object'');'
|
||||
testString: 'assert(typeof foods === "object", "<code>foods</code> is an object");'
|
||||
- text: The <code>foods</code> object has a key <code>"bananas"</code> with a value of <code>13</code>
|
||||
testString: 'assert(foods.bananas === 13, ''The <code>foods</code> object has a key <code>"bananas"</code> with a value of <code>13</code>'');'
|
||||
testString: 'assert(foods.bananas === 13, "The <code>foods</code> object has a key <code>"bananas"</code> with a value of <code>13</code>");'
|
||||
- text: The <code>foods</code> object has a key <code>"grapes"</code> with a value of <code>35</code>
|
||||
testString: 'assert(foods.grapes === 35, ''The <code>foods</code> object has a key <code>"grapes"</code> with a value of <code>35</code>'');'
|
||||
testString: 'assert(foods.grapes === 35, "The <code>foods</code> object has a key <code>"grapes"</code> with a value of <code>35</code>");'
|
||||
- text: The <code>foods</code> object has a key <code>"strawberries"</code> with a value of <code>27</code>
|
||||
testString: 'assert(foods.strawberries === 27, ''The <code>foods</code> object has a key <code>"strawberries"</code> with a value of <code>27</code>'');'
|
||||
testString: 'assert(foods.strawberries === 27, "The <code>foods</code> object has a key <code>"strawberries"</code> with a value of <code>27</code>");'
|
||||
- text: The key-value pairs should be set using dot or bracket notation
|
||||
testString: 'assert(code.search(/bananas:/) === -1 && code.search(/grapes:/) === -1 && code.search(/strawberries:/) === -1, ''The key-value pairs should be set using dot or bracket notation'');'
|
||||
testString: 'assert(code.search(/bananas:/) === -1 && code.search(/grapes:/) === -1 && code.search(/strawberries:/) === -1, "The key-value pairs should be set using dot or bracket notation");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,15 +22,15 @@ For example:
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>quickCheck(["squash", "onions", "shallots"], "mushrooms")</code> should return <code>false</code>'
|
||||
testString: 'assert.strictEqual(quickCheck([''squash'', ''onions'', ''shallots''], ''mushrooms''), false, ''<code>quickCheck(["squash", "onions", "shallots"], "mushrooms")</code> should return <code>false</code>'');'
|
||||
testString: 'assert.strictEqual(quickCheck(["squash", "onions", "shallots"], "mushrooms"), false, "<code>quickCheck(["squash", "onions", "shallots"], "mushrooms")</code> should return <code>false</code>");'
|
||||
- text: '<code>quickCheck(["squash", "onions", "shallots"], "onions")</code> should return <code>true</code>'
|
||||
testString: 'assert.strictEqual(quickCheck([''squash'', ''onions'', ''shallots''], ''onions''), true, ''<code>quickCheck(["squash", "onions", "shallots"], "onions")</code> should return <code>true</code>'');'
|
||||
testString: 'assert.strictEqual(quickCheck(["squash", "onions", "shallots"], "onions"), true, "<code>quickCheck(["squash", "onions", "shallots"], "onions")</code> should return <code>true</code>");'
|
||||
- text: '<code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> should return <code>true</code>'
|
||||
testString: 'assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true, ''<code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> should return <code>true</code>'');'
|
||||
testString: 'assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true, "<code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> should return <code>true</code>");'
|
||||
- text: '<code>quickCheck([true, false, false], undefined)</code> should return <code>false</code>'
|
||||
testString: 'assert.strictEqual(quickCheck([true, false, false], undefined), false, ''<code>quickCheck([true, false, false], undefined)</code> should return <code>false</code>'');'
|
||||
testString: 'assert.strictEqual(quickCheck([true, false, false], undefined), false, "<code>quickCheck([true, false, false], undefined)</code> should return <code>false</code>");'
|
||||
- text: The <code>quickCheck</code> function should utilize the <code>indexOf()</code> method
|
||||
testString: 'assert.notStrictEqual(quickCheck.toString().search(/\.indexOf\(/), -1, ''The <code>quickCheck</code> function should utilize the <code>indexOf()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(quickCheck.toString().search(/\.indexOf\(/), -1, "The <code>quickCheck</code> function should utilize the <code>indexOf()</code> method");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -21,11 +21,11 @@ We've created an object, <code>users</code>, with some users in it and a functio
|
||||
```yml
|
||||
tests:
|
||||
- text: 'The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>'
|
||||
testString: 'assert(''Alan'' in users && ''Jeff'' in users && ''Sarah'' in users && ''Ryan'' in users && Object.keys(users).length === 4, ''The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>'');'
|
||||
testString: 'assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4, "The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>");'
|
||||
- text: 'The function <code>isEveryoneHere</code> returns <code>true</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are properties on the <code>users</code> object'
|
||||
testString: 'assert(isEveryoneHere(users) === true, ''The function <code>isEveryoneHere</code> returns <code>true</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are properties on the <code>users</code> object'');'
|
||||
testString: 'assert(isEveryoneHere(users) === true, "The function <code>isEveryoneHere</code> returns <code>true</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are properties on the <code>users</code> object");'
|
||||
- text: 'The function <code>isEveryoneHere</code> returns <code>false</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are not properties on the <code>users</code> object'
|
||||
testString: 'assert((function() { delete users.Alan; delete users.Jeff; delete users.Sarah; delete users.Ryan; return isEveryoneHere(users) })() === false, ''The function <code>isEveryoneHere</code> returns <code>false</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are not properties on the <code>users</code> object'');'
|
||||
testString: 'assert((function() { delete users.Alan; delete users.Jeff; delete users.Sarah; delete users.Ryan; return isEveryoneHere(users) })() === false, "The function <code>isEveryoneHere</code> returns <code>false</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are not properties on the <code>users</code> object");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,9 +22,9 @@ We have defined a function <code>spreadOut</code> that returns the variable <cod
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>'
|
||||
testString: 'assert.deepEqual(spreadOut(), [''learning'', ''to'', ''code'', ''is'', ''fun''], ''<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>'');'
|
||||
testString: 'assert.deepEqual(spreadOut(), ["learning", "to", "code", "is", "fun"], "<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>");'
|
||||
- text: The <code>spreadOut</code> function should utilize spread syntax
|
||||
testString: 'assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, ''The <code>spreadOut</code> function should utilize spread syntax'');'
|
||||
testString: 'assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, "The <code>spreadOut</code> function should utilize spread syntax");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,15 +22,15 @@ We have defined a function, <code>copyMachine</code> which takes <code>arr</code
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>copyMachine([true, false, true], 2)</code> should return <code>[[true, false, true], [true, false, true]]</code>'
|
||||
testString: 'assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], ''<code>copyMachine([true, false, true], 2)</code> should return <code>[[true, false, true], [true, false, true]]</code>'');'
|
||||
testString: 'assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], "<code>copyMachine([true, false, true], 2)</code> should return <code>[[true, false, true], [true, false, true]]</code>");'
|
||||
- text: '<code>copyMachine([1, 2, 3], 5)</code> should return <code>[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]</code>'
|
||||
testString: 'assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], ''<code>copyMachine([1, 2, 3], 5)</code> should return <code>[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]</code>'');'
|
||||
testString: 'assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], "<code>copyMachine([1, 2, 3], 5)</code> should return <code>[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]</code>");'
|
||||
- text: '<code>copyMachine([true, true, null], 1)</code> should return <code>[[true, true, null]]</code>'
|
||||
testString: 'assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], ''<code>copyMachine([true, true, null], 1)</code> should return <code>[[true, true, null]]</code>'');'
|
||||
testString: 'assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], "<code>copyMachine([true, true, null], 1)</code> should return <code>[[true, true, null]]</code>");'
|
||||
- text: '<code>copyMachine(["it works"], 3)</code> should return <code>[["it works"], ["it works"], ["it works"]]</code>'
|
||||
testString: 'assert.deepEqual(copyMachine([''it works''], 3), [[''it works''], [''it works''], [''it works'']], ''<code>copyMachine(["it works"], 3)</code> should return <code>[["it works"], ["it works"], ["it works"]]</code>'');'
|
||||
testString: 'assert.deepEqual(copyMachine(["it works"], 3), [["it works"], ["it works"], ["it works"]], "<code>copyMachine(["it works"], 3)</code> should return <code>[["it works"], ["it works"], ["it works"]]</code>");'
|
||||
- text: The <code>copyMachine</code> function should utilize the <code>spread operator</code> with array <code>arr</code>
|
||||
testString: 'assert.notStrictEqual(copyMachine.toString().indexOf(''.concat(_toConsumableArray(arr))''), -1, ''The <code>copyMachine</code> function should utilize the <code>spread operator</code> with array <code>arr</code>'');'
|
||||
testString: 'assert.notStrictEqual(copyMachine.toString().indexOf(".concat(_toConsumableArray(arr))"), -1, "The <code>copyMachine</code> function should utilize the <code>spread operator</code> with array <code>arr</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,9 +22,9 @@ We have defined a function, <code>forecast</code>, that takes an array as an arg
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>forecast</code> should return <code>["warm", "sunny"]'
|
||||
testString: 'assert.deepEqual(forecast([''cold'', ''rainy'', ''warm'', ''sunny'', ''cool'', ''thunderstorms'']), [''warm'', ''sunny''], ''<code>forecast</code> should return <code>["warm", "sunny"]'');'
|
||||
testString: 'assert.deepEqual(forecast(["cold", "rainy", "warm", "sunny", "cool", "thunderstorms"]), ["warm", "sunny"], "<code>forecast</code> should return <code>["warm", "sunny"]");'
|
||||
- text: The <code>forecast</code> function should utilize the <code>slice()</code> method
|
||||
testString: 'assert(/\.slice\(/.test(code), ''The <code>forecast</code> function should utilize the <code>slice()</code> method'');'
|
||||
testString: 'assert(/\.slice\(/.test(code), "The <code>forecast</code> function should utilize the <code>slice()</code> method");'
|
||||
|
||||
```
|
||||
|
||||
@@ -38,7 +38,7 @@ tests:
|
||||
```js
|
||||
function forecast(arr) {
|
||||
// change code below this line
|
||||
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
@@ -27,15 +27,15 @@ We have defined a variable, <code>myNestedArray</code>, set equal to an array. M
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myNestedArray</code> should contain only numbers, booleans, and strings as data elements'
|
||||
testString: 'assert.strictEqual((function(arr) { let flattened = (function flatten(arr) { const flat = [].concat(...arr); return flat.some (Array.isArray) ? flatten(flat) : flat; })(arr); for (let i = 0; i < flattened.length; i++) { if ( typeof flattened[i] !== ''number'' && typeof flattened[i] !== ''string'' && typeof flattened[i] !== ''boolean'') { return false } } return true })(myNestedArray), true, ''<code>myNestedArray</code> should contain only numbers, booleans, and strings as data elements'');'
|
||||
testString: 'assert.strictEqual((function(arr) { let flattened = (function flatten(arr) { const flat = [].concat(...arr); return flat.some (Array.isArray) ? flatten(flat) : flat; })(arr); for (let i = 0; i < flattened.length; i++) { if ( typeof flattened[i] !== "number" && typeof flattened[i] !== "string" && typeof flattened[i] !== "boolean") { return false } } return true })(myNestedArray), true, "<code>myNestedArray</code> should contain only numbers, booleans, and strings as data elements");'
|
||||
- text: <code>myNestedArray</code> should have exactly 5 levels of depth
|
||||
testString: 'assert.strictEqual((function(arr) {let depth = 0;function arrayDepth(array, i, d) { if (Array.isArray(array[i])) { arrayDepth(array[i], 0, d + 1);} else { depth = (d > depth) ? d : depth;}if (i < array.length) { arrayDepth(array, i + 1, d);} }arrayDepth(arr, 0, 0);return depth;})(myNestedArray), 4, ''<code>myNestedArray</code> should have exactly 5 levels of depth'');'
|
||||
testString: 'assert.strictEqual((function(arr) {let depth = 0;function arrayDepth(array, i, d) { if (Array.isArray(array[i])) { arrayDepth(array[i], 0, d + 1);} else { depth = (d > depth) ? d : depth;}if (i < array.length) { arrayDepth(array, i + 1, d);} }arrayDepth(arr, 0, 0);return depth;})(myNestedArray), 4, "<code>myNestedArray</code> should have exactly 5 levels of depth");'
|
||||
- text: <code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deep"</code> on an array nested 3 levels deep
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deep'').length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deep'')[0] === 2, ''<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deep"</code> on an array nested 3 levels deep'');'
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deep").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deep")[0] === 2, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deep"</code> on an array nested 3 levels deep");'
|
||||
- text: <code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deeper"</code> on an array nested 4 levels deep
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deeper'').length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deeper'')[0] === 3, ''<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deeper"</code> on an array nested 4 levels deep'');'
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deeper").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deeper")[0] === 3, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deeper"</code> on an array nested 4 levels deep");'
|
||||
- text: <code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deepest"</code> on an array nested 5 levels deep
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deepest'').length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, ''deepest'')[0] === 4, ''<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deepest"</code> on an array nested 5 levels deep'');'
|
||||
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deepest").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deepest")[0] === 4, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deepest"</code> on an array nested 5 levels deep");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -20,9 +20,9 @@ Finish writing the <code>getArrayOfUsers</code> function so that it returns an a
|
||||
```yml
|
||||
tests:
|
||||
- text: 'The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>'
|
||||
testString: 'assert(''Alan'' in users && ''Jeff'' in users && ''Sarah'' in users && ''Ryan'' in users && Object.keys(users).length === 4, ''The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>'');'
|
||||
testString: 'assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4, "The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>");'
|
||||
- text: The <code>getArrayOfUsers</code> function returns an array which contains all the keys in the <code>users</code> object
|
||||
testString: 'assert((function() { users.Sam = {}; users.Lewis = {}; let R = getArrayOfUsers(users); return (R.indexOf(''Alan'') !== -1 && R.indexOf(''Jeff'') !== -1 && R.indexOf(''Sarah'') !== -1 && R.indexOf(''Ryan'') !== -1 && R.indexOf(''Sam'') !== -1 && R.indexOf(''Lewis'') !== -1); })() === true, ''The <code>getArrayOfUsers</code> function returns an array which contains all the keys in the <code>users</code> object'');'
|
||||
testString: 'assert((function() { users.Sam = {}; users.Lewis = {}; let R = getArrayOfUsers(users); return (R.indexOf("Alan") !== -1 && R.indexOf("Jeff") !== -1 && R.indexOf("Sarah") !== -1 && R.indexOf("Ryan") !== -1 && R.indexOf("Sam") !== -1 && R.indexOf("Lewis") !== -1); })() === true, "The <code>getArrayOfUsers</code> function returns an array which contains all the keys in the <code>users</code> object");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,15 +23,15 @@ We have defined a function, <code>filteredArray</code>, which takes <code>arr</c
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)</code> should return <code>[ [10, 8, 3], [14, 6, 23] ]</code>'
|
||||
testString: 'assert.deepEqual(filteredArray([ [10, 8, 3], [14, 6, 23], [3, 18, 6] ], 18), [[10, 8, 3], [14, 6, 23]], ''<code>filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)</code> should return <code>[ [10, 8, 3], [14, 6, 23] ]</code>'');'
|
||||
testString: 'assert.deepEqual(filteredArray([ [10, 8, 3], [14, 6, 23], [3, 18, 6] ], 18), [[10, 8, 3], [14, 6, 23]], "<code>filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)</code> should return <code>[ [10, 8, 3], [14, 6, 23] ]</code>");'
|
||||
- text: '<code>filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2)</code> should return <code>[ ["flutes", 4] ]</code>'
|
||||
testString: 'assert.deepEqual(filteredArray([ [''trumpets'', 2], [''flutes'', 4], [''saxophones'', 2] ], 2), [[''flutes'', 4]], ''<code>filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2)</code> should return <code>[ ["flutes", 4] ]</code>'');'
|
||||
testString: 'assert.deepEqual(filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2), [["flutes", 4]], "<code>filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2)</code> should return <code>[ ["flutes", 4] ]</code>");'
|
||||
- text: '<code>filteredArray([ ["amy", "beth", "sam"], ["dave", "sean", "peter"] ], "peter")</code> should return <code>[ ["amy", "beth", "sam"] ]</code>'
|
||||
testString: 'assert.deepEqual(filteredArray([[''amy'', ''beth'', ''sam''], [''dave'', ''sean'', ''peter'']], ''peter''), [[''amy'', ''beth'', ''sam'']], ''<code>filteredArray([ ["amy", "beth", "sam"], ["dave", "sean", "peter"] ], "peter")</code> should return <code>[ ["amy", "beth", "sam"] ]</code>'');'
|
||||
testString: 'assert.deepEqual(filteredArray([["amy", "beth", "sam"], ["dave", "sean", "peter"]], "peter"), [["amy", "beth", "sam"]], "<code>filteredArray([ ["amy", "beth", "sam"], ["dave", "sean", "peter"] ], "peter")</code> should return <code>[ ["amy", "beth", "sam"] ]</code>");'
|
||||
- text: '<code>filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)</code> should return <code>[ ]</code>'
|
||||
testString: 'assert.deepEqual(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3), [], ''<code>filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)</code> should return <code>[ ]</code>'');'
|
||||
testString: 'assert.deepEqual(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3), [], "<code>filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)</code> should return <code>[ ]</code>");'
|
||||
- text: The <code>filteredArray</code> function should utilize a <code>for</code> loop
|
||||
testString: 'assert.notStrictEqual(filteredArray.toString().search(/for/), -1, ''The <code>filteredArray</code> function should utilize a <code>for</code> loop'');'
|
||||
testString: 'assert.notStrictEqual(filteredArray.toString().search(/for/), -1, "The <code>filteredArray</code> function should utilize a <code>for</code> loop");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -20,11 +20,11 @@ Take a look at the object we've provided in the code editor. The <code>user</cod
|
||||
```yml
|
||||
tests:
|
||||
- text: 'The <code>user</code> object has <code>name</code>, <code>age</code>, and <code>data</code> keys'
|
||||
testString: 'assert(''name'' in user && ''age'' in user && ''data'' in user, ''The <code>user</code> object has <code>name</code>, <code>age</code>, and <code>data</code> keys'');'
|
||||
testString: 'assert("name" in user && "age" in user && "data" in user, "The <code>user</code> object has <code>name</code>, <code>age</code>, and <code>data</code> keys");'
|
||||
- text: The <code>addFriend</code> function accepts a <code>user</code> object and a <code>friend</code> string as arguments and adds the friend to the array of <code>friends</code> in the <code>user</code> object
|
||||
testString: 'assert((function() { let L1 = user.data.friends.length; addFriend(user, ''Sean''); let L2 = user.data.friends.length; return (L2 === L1 + 1); })(), ''The <code>addFriend</code> function accepts a <code>user</code> object and a <code>friend</code> string as arguments and adds the friend to the array of <code>friends</code> in the <code>user</code> object'');'
|
||||
testString: 'assert((function() { let L1 = user.data.friends.length; addFriend(user, "Sean"); let L2 = user.data.friends.length; return (L2 === L1 + 1); })(), "The <code>addFriend</code> function accepts a <code>user</code> object and a <code>friend</code> string as arguments and adds the friend to the array of <code>friends</code> in the <code>user</code> object");'
|
||||
- text: '<code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>'
|
||||
testString: 'assert.deepEqual((function() { delete user.data.friends; user.data.friends = [''Sam'', ''Kira'', ''Tomo'']; return addFriend(user, ''Pete'') })(), [''Sam'', ''Kira'', ''Tomo'', ''Pete''], ''<code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>'');'
|
||||
testString: 'assert.deepEqual((function() { delete user.data.friends; user.data.friends = ["Sam", "Kira", "Tomo"]; return addFriend(user, "Pete") })(), ["Sam", "Kira", "Tomo", "Pete"], "<code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>");'
|
||||
|
||||
```
|
||||
|
||||
@@ -57,7 +57,7 @@ let user = {
|
||||
};
|
||||
|
||||
function addFriend(userObj, friend) {
|
||||
// change code below this line
|
||||
// change code below this line
|
||||
|
||||
// change code above this line
|
||||
}
|
||||
|
@@ -22,13 +22,13 @@ Here we've defined an object, <code>userActivity</code>, which includes another
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>userActivity</code> has <code>id</code>, <code>date</code> and <code>data</code> properties'
|
||||
testString: 'assert(''id'' in userActivity && ''date'' in userActivity && ''data'' in userActivity, ''<code>userActivity</code> has <code>id</code>, <code>date</code> and <code>data</code> properties'');'
|
||||
testString: 'assert("id" in userActivity && "date" in userActivity && "data" in userActivity, "<code>userActivity</code> has <code>id</code>, <code>date</code> and <code>data</code> properties");'
|
||||
- text: <code>userActivity</code> has a <code>data</code> key set to an object with keys <code>totalUsers</code> and <code>online</code>
|
||||
testString: 'assert(''totalUsers'' in userActivity.data && ''online'' in userActivity.data, ''<code>userActivity</code> has a <code>data</code> key set to an object with keys <code>totalUsers</code> and <code>online</code>'');'
|
||||
testString: 'assert("totalUsers" in userActivity.data && "online" in userActivity.data, "<code>userActivity</code> has a <code>data</code> key set to an object with keys <code>totalUsers</code> and <code>online</code>");'
|
||||
- text: The <code>online</code> property nested in the <code>data</code> key of <code>userActivity</code> should be set to <code>45</code>
|
||||
testString: 'assert(userActivity.data.online === 45, ''The <code>online</code> property nested in the <code>data</code> key of <code>userActivity</code> should be set to <code>45</code>'');'
|
||||
testString: 'assert(userActivity.data.online === 45, "The <code>online</code> property nested in the <code>data</code> key of <code>userActivity</code> should be set to <code>45</code>");'
|
||||
- text: The <code>online</code> property is set using dot or bracket notation
|
||||
testString: 'assert.strictEqual(code.search(/online: 45/), -1, ''The <code>online</code> property is set using dot or bracket notation'');'
|
||||
testString: 'assert.strictEqual(code.search(/online: 45/), -1, "The <code>online</code> property is set using dot or bracket notation");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,11 +24,11 @@ We have defined a function, <code>popShift</code>, which takes an array as an ar
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>popShift(["challenge", "is", "not", "complete"])</code> should return <code>["challenge", "complete"]</code>'
|
||||
testString: 'assert.deepEqual(popShift([''challenge'', ''is'', ''not'', ''complete'']), ["challenge", "complete"], ''<code>popShift(["challenge", "is", "not", "complete"])</code> should return <code>["challenge", "complete"]</code>'');'
|
||||
testString: 'assert.deepEqual(popShift(["challenge", "is", "not", "complete"]), ["challenge", "complete"], "<code>popShift(["challenge", "is", "not", "complete"])</code> should return <code>["challenge", "complete"]</code>");'
|
||||
- text: The <code>popShift</code> function should utilize the <code>pop()</code> method
|
||||
testString: 'assert.notStrictEqual(popShift.toString().search(/\.pop\(/), -1, ''The <code>popShift</code> function should utilize the <code>pop()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(popShift.toString().search(/\.pop\(/), -1, "The <code>popShift</code> function should utilize the <code>pop()</code> method");'
|
||||
- text: The <code>popShift</code> function should utilize the <code>shift()</code> method
|
||||
testString: 'assert.notStrictEqual(popShift.toString().search(/\.shift\(/), -1, ''The <code>popShift</code> function should utilize the <code>shift()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(popShift.toString().search(/\.shift\(/), -1, "The <code>popShift</code> function should utilize the <code>shift()</code> method");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,9 +24,9 @@ We've defined a function, <code>sumOfTen</code>, which takes an array as an argu
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sumOfTen</code> should return 10
|
||||
testString: 'assert.strictEqual(sumOfTen([2, 5, 1, 5, 2, 1]), 10, ''<code>sumOfTen</code> should return 10'');'
|
||||
testString: 'assert.strictEqual(sumOfTen([2, 5, 1, 5, 2, 1]), 10, "<code>sumOfTen</code> should return 10");'
|
||||
- text: The <code>sumOfTen</code> function should utilize the <code>splice()</code> method
|
||||
testString: 'assert.notStrictEqual(sumOfTen.toString().search(/\.splice\(/), -1, ''The <code>sumOfTen</code> function should utilize the <code>splice()</code> method'');'
|
||||
testString: 'assert.notStrictEqual(sumOfTen.toString().search(/\.splice\(/), -1, "The <code>sumOfTen</code> function should utilize the <code>splice()</code> method");'
|
||||
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ tests:
|
||||
```js
|
||||
function sumOfTen(arr) {
|
||||
// change code below this line
|
||||
|
||||
|
||||
// change code above this line
|
||||
return arr.reduce((a, b) => a + b);
|
||||
}
|
||||
|
@@ -24,15 +24,15 @@ We have defined a variable called <code>yourArray</code>. Complete the statement
|
||||
```yml
|
||||
tests:
|
||||
- text: yourArray is an array
|
||||
testString: 'assert.strictEqual(Array.isArray(yourArray), true, ''yourArray is an array'');'
|
||||
testString: 'assert.strictEqual(Array.isArray(yourArray), true, "yourArray is an array");'
|
||||
- text: <code>yourArray</code> is at least 5 elements long
|
||||
testString: 'assert.isAtLeast(yourArray.length, 5, ''<code>yourArray</code> is at least 5 elements long'');'
|
||||
testString: 'assert.isAtLeast(yourArray.length, 5, "<code>yourArray</code> is at least 5 elements long");'
|
||||
- text: <code>yourArray</code> contains at least one <code>boolean</code>
|
||||
testString: 'assert(yourArray.filter( el => typeof el === ''boolean'').length >= 1, ''<code>yourArray</code> contains at least one <code>boolean</code>'');'
|
||||
testString: 'assert(yourArray.filter( el => typeof el === "boolean").length >= 1, "<code>yourArray</code> contains at least one <code>boolean</code>");'
|
||||
- text: <code>yourArray</code> contains at least one <code>number</code>
|
||||
testString: 'assert(yourArray.filter( el => typeof el === ''number'').length >= 1, ''<code>yourArray</code> contains at least one <code>number</code>'');'
|
||||
testString: 'assert(yourArray.filter( el => typeof el === "number").length >= 1, "<code>yourArray</code> contains at least one <code>number</code>");'
|
||||
- text: <code>yourArray</code> contains at least one <code>string</code>
|
||||
testString: 'assert(yourArray.filter( el => typeof el === ''string'').length >= 1, ''<code>yourArray</code> contains at least one <code>string</code>'');'
|
||||
testString: 'assert(yourArray.filter( el => typeof el === "string").length >= 1, "<code>yourArray</code> contains at least one <code>string</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,9 +23,9 @@ Use the delete keyword to remove the <code>oranges</code>, <code>plums</code>, a
|
||||
```yml
|
||||
tests:
|
||||
- text: 'The <code>foods</code> object only has three keys: <code>apples</code>, <code>grapes</code>, and <code>bananas</code>'
|
||||
testString: 'assert(!foods.hasOwnProperty(''oranges'') && !foods.hasOwnProperty(''plums'') && !foods.hasOwnProperty(''strawberries'') && Object.keys(foods).length === 3, ''The <code>foods</code> object only has three keys: <code>apples</code>, <code>grapes</code>, and <code>bananas</code>'');'
|
||||
testString: 'assert(!foods.hasOwnProperty("oranges") && !foods.hasOwnProperty("plums") && !foods.hasOwnProperty("strawberries") && Object.keys(foods).length === 3, "The <code>foods</code> object only has three keys: <code>apples</code>, <code>grapes</code>, and <code>bananas</code>");'
|
||||
- text: 'The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys are removed using <code>delete</code>'
|
||||
testString: 'assert(code.search(/oranges:/) !== -1 && code.search(/plums:/) !== -1 && code.search(/strawberries:/) !== -1, ''The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys are removed using <code>delete</code>'');'
|
||||
testString: 'assert(code.search(/oranges:/) !== -1 && code.search(/plums:/) !== -1 && code.search(/strawberries:/) !== -1, "The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys are removed using <code>delete</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,9 +25,9 @@ Create a variable called <code>myData</code> and set it to equal the first value
|
||||
```yml
|
||||
tests:
|
||||
- text: The variable <code>myData</code> should equal the first value of <code>myArray</code>.
|
||||
testString: 'assert((function(){if(typeof myArray !== ''undefined'' && typeof myData !== ''undefined'' && myArray[0] === myData){return true;}else{return false;}})(), ''The variable <code>myData</code> should equal the first value of <code>myArray</code>.'');'
|
||||
testString: 'assert((function(){if(typeof myArray !== "undefined" && typeof myData !== "undefined" && myArray[0] === myData){return true;}else{return false;}})(), "The variable <code>myData</code> should equal the first value of <code>myArray</code>.");'
|
||||
- text: The data in variable <code>myArray</code> should be accessed using bracket notation.
|
||||
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), ''The data in variable <code>myArray</code> should be accessed using bracket notation.'');'
|
||||
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), "The data in variable <code>myArray</code> should be accessed using bracket notation.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,9 +24,9 @@ Using bracket notation select an element from <code>myArray</code> such that <co
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myData</code> should be equal to <code>8</code>.
|
||||
testString: 'assert(myData === 8, ''<code>myData</code> should be equal to <code>8</code>.'');'
|
||||
testString: 'assert(myData === 8, "<code>myData</code> should be equal to <code>8</code>.");'
|
||||
- text: You should be using bracket notation to read the correct value from <code>myArray</code>.
|
||||
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), ''You should be using bracket notation to read the correct value from <code>myArray</code>.'');'
|
||||
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from <code>myArray</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,9 +23,9 @@ Retrieve the second tree from the variable <code>myPlants</code> using object do
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>secondTree</code> should equal "pine"
|
||||
testString: 'assert(secondTree === "pine", ''<code>secondTree</code> should equal "pine"'');'
|
||||
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
|
||||
- text: Use dot and bracket notation to access <code>myPlants</code>
|
||||
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), ''Use dot and bracket notation to access <code>myPlants</code>'');'
|
||||
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
|
||||
|
||||
```
|
||||
|
||||
@@ -39,7 +39,7 @@ tests:
|
||||
```js
|
||||
// Setup
|
||||
var myPlants = [
|
||||
{
|
||||
{
|
||||
type: "flowers",
|
||||
list: [
|
||||
"rose",
|
||||
@@ -54,7 +54,7 @@ var myPlants = [
|
||||
"pine",
|
||||
"birch"
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// Only change code below this line
|
||||
@@ -83,7 +83,7 @@ console.info('after the test');
|
||||
|
||||
```js
|
||||
var myPlants = [
|
||||
{
|
||||
{
|
||||
type: "flowers",
|
||||
list: [
|
||||
"rose",
|
||||
@@ -98,7 +98,7 @@ var myPlants = [
|
||||
"pine",
|
||||
"birch"
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// Only change code below this line
|
||||
|
@@ -23,9 +23,9 @@ Access the <code>myStorage</code> object and assign the contents of the <code>gl
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>gloveBoxContents</code> should equal "maps"
|
||||
testString: 'assert(gloveBoxContents === "maps", ''<code>gloveBoxContents</code> should equal "maps"'');'
|
||||
testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
|
||||
- text: Use dot and bracket notation to access <code>myStorage</code>
|
||||
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|'')glove box\1\s*\]/g.test(code), ''Use dot and bracket notation to access <code>myStorage</code>'');'
|
||||
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'
|
||||
|
||||
```
|
||||
|
||||
@@ -73,13 +73,13 @@ console.info('after the test');
|
||||
|
||||
|
||||
```js
|
||||
var myStorage = {
|
||||
"car":{
|
||||
"inside":{
|
||||
var myStorage = {
|
||||
"car":{
|
||||
"inside":{
|
||||
"glove box":"maps",
|
||||
"passenger seat":"crumbs"
|
||||
},
|
||||
"outside":{
|
||||
"outside":{
|
||||
"trunk":"jack"
|
||||
}
|
||||
}
|
||||
|
@@ -25,15 +25,15 @@ Read the values of the properties <code>"an entree"</code> and <code>"the drink"
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>entreeValue</code> should be a string
|
||||
testString: 'assert(typeof entreeValue === ''string'' , ''<code>entreeValue</code> should be a string'');'
|
||||
testString: 'assert(typeof entreeValue === "string" , "<code>entreeValue</code> should be a string");'
|
||||
- text: The value of <code>entreeValue</code> should be <code>"hamburger"</code>
|
||||
testString: 'assert(entreeValue === ''hamburger'' , ''The value of <code>entreeValue</code> should be <code>"hamburger"</code>'');'
|
||||
testString: 'assert(entreeValue === "hamburger" , "The value of <code>entreeValue</code> should be <code>"hamburger"</code>");'
|
||||
- text: <code>drinkValue</code> should be a string
|
||||
testString: 'assert(typeof drinkValue === ''string'' , ''<code>drinkValue</code> should be a string'');'
|
||||
testString: 'assert(typeof drinkValue === "string" , "<code>drinkValue</code> should be a string");'
|
||||
- text: The value of <code>drinkValue</code> should be <code>"water"</code>
|
||||
testString: 'assert(drinkValue === ''water'' , ''The value of <code>drinkValue</code> should be <code>"water"</code>'');'
|
||||
testString: 'assert(drinkValue === "water" , "The value of <code>drinkValue</code> should be <code>"water"</code>");'
|
||||
- text: You should use bracket notation twice
|
||||
testString: 'assert(code.match(/testObj\s*?\[(''|")[^''"]+\1\]/g).length > 1, ''You should use bracket notation twice'');'
|
||||
testString: 'assert(code.match(/testObj\s*?\[("|")[^""]+\1\]/g).length > 1, "You should use bracket notation twice");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,15 +23,15 @@ Read in the property values of <code>testObj</code> using dot notation. Set the
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>hatValue</code> should be a string
|
||||
testString: 'assert(typeof hatValue === ''string'' , ''<code>hatValue</code> should be a string'');'
|
||||
testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
|
||||
- text: The value of <code>hatValue</code> should be <code>"ballcap"</code>
|
||||
testString: 'assert(hatValue === ''ballcap'' , ''The value of <code>hatValue</code> should be <code>"ballcap"</code>'');'
|
||||
testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
|
||||
- text: <code>shirtValue</code> should be a string
|
||||
testString: 'assert(typeof shirtValue === ''string'' , ''<code>shirtValue</code> should be a string'');'
|
||||
testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
|
||||
- text: The value of <code>shirtValue</code> should be <code>"jersey"</code>
|
||||
testString: 'assert(shirtValue === ''jersey'' , ''The value of <code>shirtValue</code> should be <code>"jersey"</code>'');'
|
||||
testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
|
||||
- text: You should use dot notation twice
|
||||
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, ''You should use dot notation twice'');'
|
||||
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
|
||||
|
||||
```
|
||||
|
||||
@@ -81,7 +81,7 @@ var testObj = {
|
||||
"shoes": "cleats"
|
||||
};
|
||||
|
||||
var hatValue = testObj.hat;
|
||||
var hatValue = testObj.hat;
|
||||
var shirtValue = testObj.shirt;
|
||||
```
|
||||
|
||||
|
@@ -28,17 +28,17 @@ Use the <code>playerNumber</code> variable to look up player <code>16</code> in
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>playerNumber</code> should be a number
|
||||
testString: 'assert(typeof playerNumber === ''number'', ''<code>playerNumber</code> should be a number'');'
|
||||
testString: 'assert(typeof playerNumber === "number", "<code>playerNumber</code> should be a number");'
|
||||
- text: The variable <code>player</code> should be a string
|
||||
testString: 'assert(typeof player === ''string'', ''The variable <code>player</code> should be a string'');'
|
||||
testString: 'assert(typeof player === "string", "The variable <code>player</code> should be a string");'
|
||||
- text: The value of <code>player</code> should be "Montana"
|
||||
testString: 'assert(player === ''Montana'', ''The value of <code>player</code> should be "Montana"'');'
|
||||
testString: 'assert(player === "Montana", "The value of <code>player</code> should be "Montana"");'
|
||||
- text: You should use bracket notation to access <code>testObj</code>
|
||||
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),''You should use bracket notation to access <code>testObj</code>'');'
|
||||
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),"You should use bracket notation to access <code>testObj</code>");'
|
||||
- text: You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.
|
||||
testString: 'assert(!code.match(/player\s*=\s*"|\''\s*Montana\s*"|\''\s*;/gi),''You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.'');'
|
||||
testString: 'assert(!code.match(/player\s*=\s*"|\"\s*Montana\s*"|\"\s*;/gi),"You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.");'
|
||||
- text: You should be using the variable <code>playerNumber</code> in your bracket notation
|
||||
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),''You should be using the variable <code>playerNumber</code> in your bracket notation'');'
|
||||
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),"You should be using the variable <code>playerNumber</code> in your bracket notation");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ challengeType: 1
|
||||
<section id='description'>
|
||||
You can add new properties to existing JavaScript objects the same way you would modify them.
|
||||
Here's how we would add a <code>"bark"</code> property to <code>ourDog</code>:
|
||||
<code>ourDog.bark = "bow-wow";</code>
|
||||
<code>ourDog.bark = "bow-wow";</code>
|
||||
or
|
||||
<code>ourDog["bark"] = "bow-wow";</code>
|
||||
Now when we evaluate <code>ourDog.bark</code>, we'll get his bark, "bow-wow".
|
||||
@@ -25,9 +25,9 @@ Add a <code>"bark"</code> property to <code>myDog</code> and set it to a dog sou
|
||||
```yml
|
||||
tests:
|
||||
- text: Add the property <code>"bark"</code> to <code>myDog</code>.
|
||||
testString: 'assert(myDog.bark !== undefined, ''Add the property <code>"bark"</code> to <code>myDog</code>.'');'
|
||||
testString: 'assert(myDog.bark !== undefined, "Add the property <code>"bark"</code> to <code>myDog</code>.");'
|
||||
- text: Do not add <code>"bark"</code> to the setup section
|
||||
testString: 'assert(!/bark[^\n]:/.test(code), ''Do not add <code>"bark"</code> to the setup section'');'
|
||||
testString: 'assert(!/bark[^\n]:/.test(code), "Do not add <code>"bark"</code> to the setup section");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,9 +24,9 @@ Change the <code>0</code> so that sum will equal <code>20</code>.
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sum</code> should equal <code>20</code>
|
||||
testString: 'assert(sum === 20, ''<code>sum</code> should equal <code>20</code>'');'
|
||||
testString: 'assert(sum === 20, "<code>sum</code> should equal <code>20</code>");'
|
||||
- text: Use the <code>+</code> operator
|
||||
testString: 'assert(/\+/.test(code), ''Use the <code>+</code> operator'');'
|
||||
testString: 'assert(/\+/.test(code), "Use the <code>+</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,21 +23,21 @@ Write a switch statement to set <code>answer</code> for the following conditions
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>switchOfStuff("a")</code> should have a value of "apple"
|
||||
testString: 'assert(switchOfStuff("a") === "apple", ''<code>switchOfStuff("a")</code> should have a value of "apple"'');'
|
||||
testString: 'assert(switchOfStuff("a") === "apple", "<code>switchOfStuff("a")</code> should have a value of "apple"");'
|
||||
- text: <code>switchOfStuff("b")</code> should have a value of "bird"
|
||||
testString: 'assert(switchOfStuff("b") === "bird", ''<code>switchOfStuff("b")</code> should have a value of "bird"'');'
|
||||
testString: 'assert(switchOfStuff("b") === "bird", "<code>switchOfStuff("b")</code> should have a value of "bird"");'
|
||||
- text: <code>switchOfStuff("c")</code> should have a value of "cat"
|
||||
testString: 'assert(switchOfStuff("c") === "cat", ''<code>switchOfStuff("c")</code> should have a value of "cat"'');'
|
||||
testString: 'assert(switchOfStuff("c") === "cat", "<code>switchOfStuff("c")</code> should have a value of "cat"");'
|
||||
- text: <code>switchOfStuff("d")</code> should have a value of "stuff"
|
||||
testString: 'assert(switchOfStuff("d") === "stuff", ''<code>switchOfStuff("d")</code> should have a value of "stuff"'');'
|
||||
testString: 'assert(switchOfStuff("d") === "stuff", "<code>switchOfStuff("d")</code> should have a value of "stuff"");'
|
||||
- text: <code>switchOfStuff(4)</code> should have a value of "stuff"
|
||||
testString: 'assert(switchOfStuff(4) === "stuff", ''<code>switchOfStuff(4)</code> should have a value of "stuff"'');'
|
||||
testString: 'assert(switchOfStuff(4) === "stuff", "<code>switchOfStuff(4)</code> should have a value of "stuff"");'
|
||||
- text: You should not use any <code>if</code> or <code>else</code> statements
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), ''You should not use any <code>if</code> or <code>else</code> statements'');'
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
- text: You should use a <code>default</code> statement
|
||||
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", ''You should use a <code>default</code> statement'');'
|
||||
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a <code>default</code> statement");'
|
||||
- text: You should have at least 3 <code>break</code> statements
|
||||
testString: 'assert(code.match(/break/g).length > 2, ''You should have at least 3 <code>break</code> statements'');'
|
||||
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||||
|
||||
```
|
||||
|
||||
@@ -52,11 +52,11 @@ tests:
|
||||
function switchOfStuff(val) {
|
||||
var answer = "";
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return answer;
|
||||
}
|
||||
|
||||
// Change this value to test
|
||||
@@ -91,7 +91,7 @@ function switchOfStuff(val) {
|
||||
default:
|
||||
answer = "stuff";
|
||||
}
|
||||
return answer;
|
||||
return answer;
|
||||
}
|
||||
```
|
||||
|
||||
|
@@ -21,9 +21,9 @@ Set <code>someAdjective</code> and append it to <code>myStr</code> using the <co
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>someAdjective</code> should be set to a string at least 3 characters long
|
||||
testString: 'assert(typeof someAdjective !== ''undefined'' && someAdjective.length > 2, ''<code>someAdjective</code> should be set to a string at least 3 characters long'');'
|
||||
testString: 'assert(typeof someAdjective !== "undefined" && someAdjective.length > 2, "<code>someAdjective</code> should be set to a string at least 3 characters long");'
|
||||
- text: Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator
|
||||
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, ''Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator'');'
|
||||
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, "Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ guideUrl: 'https://guide.freecodecamp.org/certificates/assignment-with-a-returne
|
||||
## Description
|
||||
<section id='description'>
|
||||
If you'll recall from our discussion of <a href="javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank">Storing Values with the Assignment Operator</a>, everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.
|
||||
Assume we have pre-defined a function <code>sum</code> which adds two numbers together, then:
|
||||
Assume we have pre-defined a function <code>sum</code> which adds two numbers together, then:
|
||||
<code>ourSum = sum(5, 12);</code>
|
||||
will call <code>sum</code> function, which returns a value of <code>17</code> and assigns it to <code>ourSum</code> variable.
|
||||
</section>
|
||||
@@ -24,9 +24,9 @@ Call the <code>processArg</code> function with an argument of <code>7</code> and
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>processed</code> should have a value of <code>2</code>
|
||||
testString: 'assert(processed === 2, ''<code>processed</code> should have a value of <code>2</code>'');'
|
||||
testString: 'assert(processed === 2, "<code>processed</code> should have a value of <code>2</code>");'
|
||||
- text: You should assign <code>processArg</code> to <code>processed</code>
|
||||
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), ''You should assign <code>processArg</code> to <code>processed</code>'');'
|
||||
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), "You should assign <code>processArg</code> to <code>processed</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -28,15 +28,15 @@ You can set these object properties to whatever values you want, as long <code>"
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.'');'
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.");'
|
||||
- text: <code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.'');'
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.");'
|
||||
- text: <code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.'');'
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.");'
|
||||
- text: <code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), ''<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.'');'
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.");'
|
||||
- text: <code>myDog</code> should only contain all the given properties.
|
||||
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), ''<code>myDog</code> should only contain all the given properties.'');'
|
||||
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), "<code>myDog</code> should only contain all the given properties.");'
|
||||
|
||||
```
|
||||
|
||||
@@ -59,10 +59,10 @@ var ourDog = {
|
||||
// Only change code below this line.
|
||||
|
||||
var myDog = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
```
|
||||
|
||||
@@ -89,7 +89,7 @@ var myDog = {
|
||||
"name": "Camper",
|
||||
"legs": 4,
|
||||
"tails": 1,
|
||||
"friends": ["everything!"]
|
||||
"friends": ["everything!"]
|
||||
};
|
||||
```
|
||||
|
||||
|
@@ -22,31 +22,31 @@ Write chained <code>if</code>/<code>else if</code> statements to fulfill the fol
|
||||
```yml
|
||||
tests:
|
||||
- text: You should have at least four <code>else</code> statements
|
||||
testString: 'assert(code.match(/else/g).length > 3, ''You should have at least four <code>else</code> statements'');'
|
||||
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four <code>else</code> statements");'
|
||||
- text: You should have at least four <code>if</code> statements
|
||||
testString: 'assert(code.match(/if/g).length > 3, ''You should have at least four <code>if</code> statements'');'
|
||||
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four <code>if</code> statements");'
|
||||
- text: You should have at least one <code>return</code> statement
|
||||
testString: 'assert(code.match(/return/g).length >= 1, ''You should have at least one <code>return</code> statement'');'
|
||||
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one <code>return</code> statement");'
|
||||
- text: <code>testSize(0)</code> should return "Tiny"
|
||||
testString: 'assert(testSize(0) === "Tiny", ''<code>testSize(0)</code> should return "Tiny"'');'
|
||||
testString: 'assert(testSize(0) === "Tiny", "<code>testSize(0)</code> should return "Tiny"");'
|
||||
- text: <code>testSize(4)</code> should return "Tiny"
|
||||
testString: 'assert(testSize(4) === "Tiny", ''<code>testSize(4)</code> should return "Tiny"'');'
|
||||
testString: 'assert(testSize(4) === "Tiny", "<code>testSize(4)</code> should return "Tiny"");'
|
||||
- text: <code>testSize(5)</code> should return "Small"
|
||||
testString: 'assert(testSize(5) === "Small", ''<code>testSize(5)</code> should return "Small"'');'
|
||||
testString: 'assert(testSize(5) === "Small", "<code>testSize(5)</code> should return "Small"");'
|
||||
- text: <code>testSize(8)</code> should return "Small"
|
||||
testString: 'assert(testSize(8) === "Small", ''<code>testSize(8)</code> should return "Small"'');'
|
||||
testString: 'assert(testSize(8) === "Small", "<code>testSize(8)</code> should return "Small"");'
|
||||
- text: <code>testSize(10)</code> should return "Medium"
|
||||
testString: 'assert(testSize(10) === "Medium", ''<code>testSize(10)</code> should return "Medium"'');'
|
||||
testString: 'assert(testSize(10) === "Medium", "<code>testSize(10)</code> should return "Medium"");'
|
||||
- text: <code>testSize(14)</code> should return "Medium"
|
||||
testString: 'assert(testSize(14) === "Medium", ''<code>testSize(14)</code> should return "Medium"'');'
|
||||
testString: 'assert(testSize(14) === "Medium", "<code>testSize(14)</code> should return "Medium"");'
|
||||
- text: <code>testSize(15)</code> should return "Large"
|
||||
testString: 'assert(testSize(15) === "Large", ''<code>testSize(15)</code> should return "Large"'');'
|
||||
testString: 'assert(testSize(15) === "Large", "<code>testSize(15)</code> should return "Large"");'
|
||||
- text: <code>testSize(17)</code> should return "Large"
|
||||
testString: 'assert(testSize(17) === "Large", ''<code>testSize(17)</code> should return "Large"'');'
|
||||
testString: 'assert(testSize(17) === "Large", "<code>testSize(17)</code> should return "Large"");'
|
||||
- text: <code>testSize(20)</code> should return "Huge"
|
||||
testString: 'assert(testSize(20) === "Huge", ''<code>testSize(20)</code> should return "Huge"'');'
|
||||
testString: 'assert(testSize(20) === "Huge", "<code>testSize(20)</code> should return "Huge"");'
|
||||
- text: <code>testSize(25)</code> should return "Huge"
|
||||
testString: 'assert(testSize(25) === "Huge", ''<code>testSize(25)</code> should return "Huge"'');'
|
||||
testString: 'assert(testSize(25) === "Huge", "<code>testSize(25)</code> should return "Huge"");'
|
||||
|
||||
```
|
||||
|
||||
@@ -60,8 +60,8 @@ tests:
|
||||
```js
|
||||
function testSize(num) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
|
@@ -26,9 +26,9 @@ Try creating one of each type of comment.
|
||||
```yml
|
||||
tests:
|
||||
- text: Create a <code>//</code> style comment that contains at least five letters.
|
||||
testString: 'assert(code.match(/(\/\/)...../g), ''Create a <code>//</code> style comment that contains at least five letters.'');'
|
||||
testString: 'assert(code.match(/(\/\/)...../g), "Create a <code>//</code> style comment that contains at least five letters.");'
|
||||
- text: Create a <code>/* */</code> style comment that contains at least five letters.
|
||||
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), ''Create a <code>/* */</code> style comment that contains at least five letters.'');'
|
||||
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), "Create a <code>/* */</code> style comment that contains at least five letters.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,13 +25,13 @@ Add the <code>equality operator</code> to the indicated line so that the functio
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testEqual(10)</code> should return "Not Equal"
|
||||
testString: 'assert(testEqual(10) === "Not Equal", ''<code>testEqual(10)</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testEqual(10) === "Not Equal", "<code>testEqual(10)</code> should return "Not Equal"");'
|
||||
- text: <code>testEqual(12)</code> should return "Equal"
|
||||
testString: 'assert(testEqual(12) === "Equal", ''<code>testEqual(12)</code> should return "Equal"'');'
|
||||
testString: 'assert(testEqual(12) === "Equal", "<code>testEqual(12)</code> should return "Equal"");'
|
||||
- text: <code>testEqual("12")</code> should return "Equal"
|
||||
testString: 'assert(testEqual("12") === "Equal", ''<code>testEqual("12")</code> should return "Equal"'');'
|
||||
testString: 'assert(testEqual("12") === "Equal", "<code>testEqual("12")</code> should return "Equal"");'
|
||||
- text: You should use the <code>==</code> operator
|
||||
testString: 'assert(code.match(/==/g) && !code.match(/===/g), ''You should use the <code>==</code> operator'');'
|
||||
testString: 'assert(code.match(/==/g) && !code.match(/===/g), "You should use the <code>==</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,21 +23,21 @@ Add the <code>greater than</code> operator to the indicated lines so that the re
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testGreaterThan(0)</code> should return "10 or Under"
|
||||
testString: 'assert(testGreaterThan(0) === "10 or Under", ''<code>testGreaterThan(0)</code> should return "10 or Under"'');'
|
||||
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
|
||||
- text: <code>testGreaterThan(10)</code> should return "10 or Under"
|
||||
testString: 'assert(testGreaterThan(10) === "10 or Under", ''<code>testGreaterThan(10)</code> should return "10 or Under"'');'
|
||||
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
|
||||
- text: <code>testGreaterThan(11)</code> should return "Over 10"
|
||||
testString: 'assert(testGreaterThan(11) === "Over 10", ''<code>testGreaterThan(11)</code> should return "Over 10"'');'
|
||||
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(99)</code> should return "Over 10"
|
||||
testString: 'assert(testGreaterThan(99) === "Over 10", ''<code>testGreaterThan(99)</code> should return "Over 10"'');'
|
||||
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(100)</code> should return "Over 10"
|
||||
testString: 'assert(testGreaterThan(100) === "Over 10", ''<code>testGreaterThan(100)</code> should return "Over 10"'');'
|
||||
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
|
||||
- text: <code>testGreaterThan(101)</code> should return "Over 100"
|
||||
testString: 'assert(testGreaterThan(101) === "Over 100", ''<code>testGreaterThan(101)</code> should return "Over 100"'');'
|
||||
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
|
||||
- text: <code>testGreaterThan(150)</code> should return "Over 100"
|
||||
testString: 'assert(testGreaterThan(150) === "Over 100", ''<code>testGreaterThan(150)</code> should return "Over 100"'');'
|
||||
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
|
||||
- text: You should use the <code>></code> operator at least twice
|
||||
testString: 'assert(code.match(/val\s*>\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>></code> operator at least twice'');'
|
||||
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>></code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ function testGreaterThan(val) {
|
||||
if (val) { // Change this line
|
||||
return "Over 100";
|
||||
}
|
||||
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Over 10";
|
||||
}
|
||||
|
@@ -23,21 +23,21 @@ Add the <code>greater than or equal to</code> operator to the indicated lines so
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testGreaterOrEqual(0)</code> should return "Less than 10"
|
||||
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", ''<code>testGreaterOrEqual(0)</code> should return "Less than 10"'');'
|
||||
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
|
||||
- text: <code>testGreaterOrEqual(9)</code> should return "Less than 10"
|
||||
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", ''<code>testGreaterOrEqual(9)</code> should return "Less than 10"'');'
|
||||
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
|
||||
- text: <code>testGreaterOrEqual(10)</code> should return "10 or Over"
|
||||
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", ''<code>testGreaterOrEqual(10)</code> should return "10 or Over"'');'
|
||||
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(11)</code> should return "10 or Over"
|
||||
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", ''<code>testGreaterOrEqual(11)</code> should return "10 or Over"'');'
|
||||
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(19)</code> should return "10 or Over"
|
||||
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", ''<code>testGreaterOrEqual(19)</code> should return "10 or Over"'');'
|
||||
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(100)</code> should return "20 or Over"
|
||||
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", ''<code>testGreaterOrEqual(100)</code> should return "20 or Over"'');'
|
||||
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
|
||||
- text: <code>testGreaterOrEqual(21)</code> should return "20 or Over"
|
||||
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", ''<code>testGreaterOrEqual(21)</code> should return "20 or Over"'');'
|
||||
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
|
||||
- text: You should use the <code>>=</code> operator at least twice
|
||||
testString: 'assert(code.match(/val\s*>=\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code>>=</code> operator at least twice'');'
|
||||
testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>>=</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
@@ -53,7 +53,7 @@ function testGreaterOrEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "20 or Over";
|
||||
}
|
||||
|
||||
|
||||
if (val) { // Change this line
|
||||
return "10 or Over";
|
||||
}
|
||||
@@ -80,7 +80,7 @@ function testGreaterOrEqual(val) {
|
||||
if (val >= 20) { // Change this line
|
||||
return "20 or Over";
|
||||
}
|
||||
|
||||
|
||||
if (val >= 10) { // Change this line
|
||||
return "10 or Over";
|
||||
}
|
||||
|
@@ -22,17 +22,17 @@ Add the inequality operator <code>!=</code> in the <code>if</code> statement so
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testNotEqual(99)</code> should return "Equal"
|
||||
testString: 'assert(testNotEqual(99) === "Equal", ''<code>testNotEqual(99)</code> should return "Equal"'');'
|
||||
testString: 'assert(testNotEqual(99) === "Equal", "<code>testNotEqual(99)</code> should return "Equal"");'
|
||||
- text: <code>testNotEqual("99")</code> should return "Equal"
|
||||
testString: 'assert(testNotEqual("99") === "Equal", ''<code>testNotEqual("99")</code> should return "Equal"'');'
|
||||
testString: 'assert(testNotEqual("99") === "Equal", "<code>testNotEqual("99")</code> should return "Equal"");'
|
||||
- text: <code>testNotEqual(12)</code> should return "Not Equal"
|
||||
testString: 'assert(testNotEqual(12) === "Not Equal", ''<code>testNotEqual(12)</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testNotEqual(12) === "Not Equal", "<code>testNotEqual(12)</code> should return "Not Equal"");'
|
||||
- text: <code>testNotEqual("12")</code> should return "Not Equal"
|
||||
testString: 'assert(testNotEqual("12") === "Not Equal", ''<code>testNotEqual("12")</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testNotEqual("12") === "Not Equal", "<code>testNotEqual("12")</code> should return "Not Equal"");'
|
||||
- text: <code>testNotEqual("bob")</code> should return "Not Equal"
|
||||
testString: 'assert(testNotEqual("bob") === "Not Equal", ''<code>testNotEqual("bob")</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testNotEqual("bob") === "Not Equal", "<code>testNotEqual("bob")</code> should return "Not Equal"");'
|
||||
- text: You should use the <code>!=</code> operator
|
||||
testString: 'assert(code.match(/(?!!==)!=/), ''You should use the <code>!=</code> operator'');'
|
||||
testString: 'assert(code.match(/(?!!==)!=/), "You should use the <code>!=</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,19 +22,19 @@ Add the <code>less than</code> operator to the indicated lines so that the retur
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testLessThan(0)</code> should return "Under 25"
|
||||
testString: 'assert(testLessThan(0) === "Under 25", ''<code>testLessThan(0)</code> should return "Under 25"'');'
|
||||
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
|
||||
- text: <code>testLessThan(24)</code> should return "Under 25"
|
||||
testString: 'assert(testLessThan(24) === "Under 25", ''<code>testLessThan(24)</code> should return "Under 25"'');'
|
||||
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
|
||||
- text: <code>testLessThan(25)</code> should return "Under 55"
|
||||
testString: 'assert(testLessThan(25) === "Under 55", ''<code>testLessThan(25)</code> should return "Under 55"'');'
|
||||
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
|
||||
- text: <code>testLessThan(54)</code> should return "Under 55"
|
||||
testString: 'assert(testLessThan(54) === "Under 55", ''<code>testLessThan(54)</code> should return "Under 55"'');'
|
||||
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
|
||||
- text: <code>testLessThan(55)</code> should return "55 or Over"
|
||||
testString: 'assert(testLessThan(55) === "55 or Over", ''<code>testLessThan(55)</code> should return "55 or Over"'');'
|
||||
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
|
||||
- text: <code>testLessThan(99)</code> should return "55 or Over"
|
||||
testString: 'assert(testLessThan(99) === "55 or Over", ''<code>testLessThan(99)</code> should return "55 or Over"'');'
|
||||
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
|
||||
- text: You should use the <code><</code> operator at least twice
|
||||
testString: 'assert(code.match(/val\s*<\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code><</code> operator at least twice'');'
|
||||
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
@@ -50,7 +50,7 @@ function testLessThan(val) {
|
||||
if (val) { // Change this line
|
||||
return "Under 25";
|
||||
}
|
||||
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Under 55";
|
||||
}
|
||||
@@ -77,7 +77,7 @@ function testLessThan(val) {
|
||||
if (val < 25) { // Change this line
|
||||
return "Under 25";
|
||||
}
|
||||
|
||||
|
||||
if (val < 55) { // Change this line
|
||||
return "Under 55";
|
||||
}
|
||||
|
@@ -22,21 +22,21 @@ Add the <code>less than or equal to</code> operator to the indicated lines so th
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"
|
||||
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"'');'
|
||||
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: <code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"
|
||||
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"'');'
|
||||
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: <code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"
|
||||
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", ''<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"'');'
|
||||
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"");'
|
||||
- text: <code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"
|
||||
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", ''<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"'');'
|
||||
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"");'
|
||||
- text: <code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"
|
||||
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", ''<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"'');'
|
||||
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"");'
|
||||
- text: <code>testLessOrEqual(25)</code> should return "More Than 24"
|
||||
testString: 'assert(testLessOrEqual(25) === "More Than 24", ''<code>testLessOrEqual(25)</code> should return "More Than 24"'');'
|
||||
testString: 'assert(testLessOrEqual(25) === "More Than 24", "<code>testLessOrEqual(25)</code> should return "More Than 24"");'
|
||||
- text: <code>testLessOrEqual(55)</code> should return "More Than 24"
|
||||
testString: 'assert(testLessOrEqual(55) === "More Than 24", ''<code>testLessOrEqual(55)</code> should return "More Than 24"'');'
|
||||
testString: 'assert(testLessOrEqual(55) === "More Than 24", "<code>testLessOrEqual(55)</code> should return "More Than 24"");'
|
||||
- text: You should use the <code><=</code> operator at least twice
|
||||
testString: 'assert(code.match(/val\s*<=\s*(''|")*\d+(''|")*/g).length > 1, ''You should use the <code><=</code> operator at least twice'');'
|
||||
testString: 'assert(code.match(/val\s*<=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><=</code> operator at least twice");'
|
||||
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ function testLessOrEqual(val) {
|
||||
if (val) { // Change this line
|
||||
return "Smaller Than or Equal to 12";
|
||||
}
|
||||
|
||||
|
||||
if (val) { // Change this line
|
||||
return "Smaller Than or Equal to 24";
|
||||
}
|
||||
@@ -80,7 +80,7 @@ function testLessOrEqual(val) {
|
||||
if (val <= 12) { // Change this line
|
||||
return "Smaller Than or Equal to 12";
|
||||
}
|
||||
|
||||
|
||||
if (val <= 24) { // Change this line
|
||||
return "Smaller Than or Equal to 24";
|
||||
}
|
||||
|
@@ -24,13 +24,13 @@ Use the strict equality operator in the <code>if</code> statement so the functio
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testStrict(10)</code> should return "Not Equal"
|
||||
testString: 'assert(testStrict(10) === "Not Equal", ''<code>testStrict(10)</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
|
||||
- text: <code>testStrict(7)</code> should return "Equal"
|
||||
testString: 'assert(testStrict(7) === "Equal", ''<code>testStrict(7)</code> should return "Equal"'');'
|
||||
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
|
||||
- text: <code>testStrict("7")</code> should return "Not Equal"
|
||||
testString: 'assert(testStrict("7") === "Not Equal", ''<code>testStrict("7")</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</code> should return "Not Equal"");'
|
||||
- text: You should use the <code>===</code> operator
|
||||
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, ''You should use the <code>===</code> operator'');'
|
||||
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, "You should use the <code>===</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,15 +22,15 @@ Add the <code>strict inequality operator</code> to the <code>if</code> statement
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testStrictNotEqual(17)</code> should return "Equal"
|
||||
testString: 'assert(testStrictNotEqual(17) === "Equal", ''<code>testStrictNotEqual(17)</code> should return "Equal"'');'
|
||||
testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
|
||||
- text: <code>testStrictNotEqual("17")</code> should return "Not Equal"
|
||||
testString: 'assert(testStrictNotEqual("17") === "Not Equal", ''<code>testStrictNotEqual("17")</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
|
||||
- text: <code>testStrictNotEqual(12)</code> should return "Not Equal"
|
||||
testString: 'assert(testStrictNotEqual(12) === "Not Equal", ''<code>testStrictNotEqual(12)</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
|
||||
- text: <code>testStrictNotEqual("bob")</code> should return "Not Equal"
|
||||
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", ''<code>testStrictNotEqual("bob")</code> should return "Not Equal"'');'
|
||||
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
|
||||
- text: You should use the <code>!==</code> operator
|
||||
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, ''You should use the <code>!==</code> operator'');'
|
||||
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ tests:
|
||||
// Setup
|
||||
function testStrictNotEqual(val) {
|
||||
// Only Change Code Below this Line
|
||||
|
||||
|
||||
if (val) {
|
||||
|
||||
// Only Change Code Above this Line
|
||||
|
@@ -24,25 +24,25 @@ Combine the two if statements into one statement which will return <code>"Yes"</
|
||||
```yml
|
||||
tests:
|
||||
- text: You should use the <code>&&</code> operator once
|
||||
testString: 'assert(code.match(/&&/g).length === 1, ''You should use the <code>&&</code> operator once'');'
|
||||
testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
|
||||
- text: You should only have one <code>if</code> statement
|
||||
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement'');'
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
- text: <code>testLogicalAnd(0)</code> should return "No"
|
||||
testString: 'assert(testLogicalAnd(0) === "No", ''<code>testLogicalAnd(0)</code> should return "No"'');'
|
||||
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(24)</code> should return "No"
|
||||
testString: 'assert(testLogicalAnd(24) === "No", ''<code>testLogicalAnd(24)</code> should return "No"'');'
|
||||
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(25)</code> should return "Yes"
|
||||
testString: 'assert(testLogicalAnd(25) === "Yes", ''<code>testLogicalAnd(25)</code> should return "Yes"'');'
|
||||
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
|
||||
- text: <code>testLogicalAnd(30)</code> should return "Yes"
|
||||
testString: 'assert(testLogicalAnd(30) === "Yes", ''<code>testLogicalAnd(30)</code> should return "Yes"'');'
|
||||
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
|
||||
- text: <code>testLogicalAnd(50)</code> should return "Yes"
|
||||
testString: 'assert(testLogicalAnd(50) === "Yes", ''<code>testLogicalAnd(50)</code> should return "Yes"'');'
|
||||
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
|
||||
- text: <code>testLogicalAnd(51)</code> should return "No"
|
||||
testString: 'assert(testLogicalAnd(51) === "No", ''<code>testLogicalAnd(51)</code> should return "No"'');'
|
||||
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(75)</code> should return "No"
|
||||
testString: 'assert(testLogicalAnd(75) === "No", ''<code>testLogicalAnd(75)</code> should return "No"'');'
|
||||
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
|
||||
- text: <code>testLogicalAnd(80)</code> should return "No"
|
||||
testString: 'assert(testLogicalAnd(80) === "No", ''<code>testLogicalAnd(80)</code> should return "No"'');'
|
||||
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,25 +25,25 @@ Combine the two <code>if</code> statements into one statement which returns <cod
|
||||
```yml
|
||||
tests:
|
||||
- text: You should use the <code>||</code> operator once
|
||||
testString: 'assert(code.match(/\|\|/g).length === 1, ''You should use the <code>||</code> operator once'');'
|
||||
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
|
||||
- text: You should only have one <code>if</code> statement
|
||||
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement'');'
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
- text: <code>testLogicalOr(0)</code> should return "Outside"
|
||||
testString: 'assert(testLogicalOr(0) === "Outside", ''<code>testLogicalOr(0)</code> should return "Outside"'');'
|
||||
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
|
||||
- text: <code>testLogicalOr(9)</code> should return "Outside"
|
||||
testString: 'assert(testLogicalOr(9) === "Outside", ''<code>testLogicalOr(9)</code> should return "Outside"'');'
|
||||
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
|
||||
- text: <code>testLogicalOr(10)</code> should return "Inside"
|
||||
testString: 'assert(testLogicalOr(10) === "Inside", ''<code>testLogicalOr(10)</code> should return "Inside"'');'
|
||||
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(15)</code> should return "Inside"
|
||||
testString: 'assert(testLogicalOr(15) === "Inside", ''<code>testLogicalOr(15)</code> should return "Inside"'');'
|
||||
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(19)</code> should return "Inside"
|
||||
testString: 'assert(testLogicalOr(19) === "Inside", ''<code>testLogicalOr(19)</code> should return "Inside"'');'
|
||||
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(20)</code> should return "Inside"
|
||||
testString: 'assert(testLogicalOr(20) === "Inside", ''<code>testLogicalOr(20)</code> should return "Inside"'');'
|
||||
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
|
||||
- text: <code>testLogicalOr(21)</code> should return "Outside"
|
||||
testString: 'assert(testLogicalOr(21) === "Outside", ''<code>testLogicalOr(21)</code> should return "Outside"'');'
|
||||
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
|
||||
- text: <code>testLogicalOr(25)</code> should return "Outside"
|
||||
testString: 'assert(testLogicalOr(25) === "Outside", ''<code>testLogicalOr(25)</code> should return "Outside"'');'
|
||||
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,15 +24,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> should equal <code>15</code>
|
||||
testString: 'assert(a === 15, ''<code>a</code> should equal <code>15</code>'');'
|
||||
testString: 'assert(a === 15, "<code>a</code> should equal <code>15</code>");'
|
||||
- text: <code>b</code> should equal <code>26</code>
|
||||
testString: 'assert(b === 26, ''<code>b</code> should equal <code>26</code>'');'
|
||||
testString: 'assert(b === 26, "<code>b</code> should equal <code>26</code>");'
|
||||
- text: <code>c</code> should equal <code>19</code>
|
||||
testString: 'assert(c === 19, ''<code>c</code> should equal <code>19</code>'');'
|
||||
testString: 'assert(c === 19, "<code>c</code> should equal <code>19</code>");'
|
||||
- text: You should use the <code>+=</code> operator for each variable
|
||||
testString: 'assert(code.match(/\+=/g).length === 3, ''You should use the <code>+=</code> operator for each variable'');'
|
||||
testString: 'assert(code.match(/\+=/g).length === 3, "You should use the <code>+=</code> operator for each variable");'
|
||||
- text: Do not modify the code above the line
|
||||
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), ''Do not modify the code above the line'');'
|
||||
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ challengeType: 1
|
||||
<section id='description'>
|
||||
The <code>/=</code> operator divides a variable by another number.
|
||||
<code>myVar = myVar / 5;</code>
|
||||
Will divide <code>myVar</code> by <code>5</code>. This can be rewritten as:
|
||||
Will divide <code>myVar</code> by <code>5</code>. This can be rewritten as:
|
||||
<code>myVar /= 5;</code>
|
||||
</section>
|
||||
|
||||
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> should equal <code>4</code>
|
||||
testString: 'assert(a === 4, ''<code>a</code> should equal <code>4</code>'');'
|
||||
testString: 'assert(a === 4, "<code>a</code> should equal <code>4</code>");'
|
||||
- text: <code>b</code> should equal <code>27</code>
|
||||
testString: 'assert(b === 27, ''<code>b</code> should equal <code>27</code>'');'
|
||||
testString: 'assert(b === 27, "<code>b</code> should equal <code>27</code>");'
|
||||
- text: <code>c</code> should equal <code>3</code>
|
||||
testString: 'assert(c === 3, ''<code>c</code> should equal <code>3</code>'');'
|
||||
testString: 'assert(c === 3, "<code>c</code> should equal <code>3</code>");'
|
||||
- text: You should use the <code>/=</code> operator for each variable
|
||||
testString: 'assert(code.match(/\/=/g).length === 3, ''You should use the <code>/=</code> operator for each variable'');'
|
||||
testString: 'assert(code.match(/\/=/g).length === 3, "You should use the <code>/=</code> operator for each variable");'
|
||||
- text: Do not modify the code above the line
|
||||
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), ''Do not modify the code above the line'');'
|
||||
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ challengeType: 1
|
||||
<section id='description'>
|
||||
The <code>*=</code> operator multiplies a variable by a number.
|
||||
<code>myVar = myVar * 5;</code>
|
||||
will multiply <code>myVar</code> by <code>5</code>. This can be rewritten as:
|
||||
will multiply <code>myVar</code> by <code>5</code>. This can be rewritten as:
|
||||
<code>myVar *= 5;</code>
|
||||
</section>
|
||||
|
||||
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> should equal <code>25</code>
|
||||
testString: 'assert(a === 25, ''<code>a</code> should equal <code>25</code>'');'
|
||||
testString: 'assert(a === 25, "<code>a</code> should equal <code>25</code>");'
|
||||
- text: <code>b</code> should equal <code>36</code>
|
||||
testString: 'assert(b === 36, ''<code>b</code> should equal <code>36</code>'');'
|
||||
testString: 'assert(b === 36, "<code>b</code> should equal <code>36</code>");'
|
||||
- text: <code>c</code> should equal <code>46</code>
|
||||
testString: 'assert(c === 46, ''<code>c</code> should equal <code>46</code>'');'
|
||||
testString: 'assert(c === 46, "<code>c</code> should equal <code>46</code>");'
|
||||
- text: You should use the <code>*=</code> operator for each variable
|
||||
testString: 'assert(code.match(/\*=/g).length === 3, ''You should use the <code>*=</code> operator for each variable'');'
|
||||
testString: 'assert(code.match(/\*=/g).length === 3, "You should use the <code>*=</code> operator for each variable");'
|
||||
- text: Do not modify the code above the line
|
||||
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), ''Do not modify the code above the line'');'
|
||||
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -8,7 +8,7 @@ challengeType: 1
|
||||
<section id='description'>
|
||||
Like the <code>+=</code> operator, <code>-=</code> subtracts a number from a variable.
|
||||
<code>myVar = myVar - 5;</code>
|
||||
will subtract <code>5</code> from <code>myVar</code>. This can be rewritten as:
|
||||
will subtract <code>5</code> from <code>myVar</code>. This can be rewritten as:
|
||||
<code>myVar -= 5;</code>
|
||||
</section>
|
||||
|
||||
@@ -23,15 +23,15 @@ Convert the assignments for <code>a</code>, <code>b</code>, and <code>c</code> t
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code> should equal <code>5</code>
|
||||
testString: 'assert(a === 5, ''<code>a</code> should equal <code>5</code>'');'
|
||||
testString: 'assert(a === 5, "<code>a</code> should equal <code>5</code>");'
|
||||
- text: <code>b</code> should equal <code>-6</code>
|
||||
testString: 'assert(b === -6, ''<code>b</code> should equal <code>-6</code>'');'
|
||||
testString: 'assert(b === -6, "<code>b</code> should equal <code>-6</code>");'
|
||||
- text: <code>c</code> should equal <code>2</code>
|
||||
testString: 'assert(c === 2, ''<code>c</code> should equal <code>2</code>'');'
|
||||
testString: 'assert(c === 2, "<code>c</code> should equal <code>2</code>");'
|
||||
- text: You should use the <code>-=</code> operator for each variable
|
||||
testString: 'assert(code.match(/-=/g).length === 3, ''You should use the <code>-=</code> operator for each variable'');'
|
||||
testString: 'assert(code.match(/-=/g).length === 3, "You should use the <code>-=</code> operator for each variable");'
|
||||
- text: Do not modify the code above the line
|
||||
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), ''Do not modify the code above the line'');'
|
||||
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), "Do not modify the code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,13 +23,13 @@ Build <code>myStr</code> from the strings <code>"This is the start. "</code> and
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code> should have a value of <code>This is the start. This is the end.</code>
|
||||
testString: 'assert(myStr === "This is the start. This is the end.", ''<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>'');'
|
||||
testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
|
||||
- text: Use the <code>+</code> operator to build <code>myStr</code>
|
||||
testString: 'assert(code.match(/(["'']).*(["''])\s*\+\s*(["'']).*(["''])/g).length > 1, ''Use the <code>+</code> operator to build <code>myStr</code>'');'
|
||||
testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
|
||||
- text: <code>myStr</code> should be created using the <code>var</code> keyword.
|
||||
testString: 'assert(/var\s+myStr/.test(code), ''<code>myStr</code> should be created using the <code>var</code> keyword.'');'
|
||||
testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
|
||||
- text: Make sure to assign the result to the <code>myStr</code> variable.
|
||||
testString: 'assert(/myStr\s*=/.test(code), ''Make sure to assign the result to the <code>myStr</code> variable.'');'
|
||||
testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -21,9 +21,9 @@ Build <code>myStr</code> over several lines by concatenating these two strings:
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>
|
||||
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", ''<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>'');'
|
||||
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
|
||||
- text: Use the <code>+=</code> operator to build <code>myStr</code>
|
||||
testString: 'assert(code.match(/\w\s*\+=\s*["'']/g).length > 1 && code.match(/\w\s*\=\s*["'']/g).length > 1, ''Use the <code>+=</code> operator to build <code>myStr</code>'');'
|
||||
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -20,9 +20,9 @@ Set <code>myName</code> to a string equal to your name and build <code>myStr</co
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myName</code> should be set to a string at least 3 characters long
|
||||
testString: 'assert(typeof myName !== ''undefined'' && myName.length > 2, ''<code>myName</code> should be set to a string at least 3 characters long'');'
|
||||
testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
|
||||
- text: Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it
|
||||
testString: 'assert(code.match(/["'']\s*\+\s*myName\s*\+\s*["'']/g).length > 0, ''Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it'');'
|
||||
testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,11 +25,11 @@ Push the odd numbers from 9 through 1 to <code>myArray</code> using a <code>for<
|
||||
```yml
|
||||
tests:
|
||||
- text: You should be using a <code>for</code> loop for this.
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: You should be using the array method <code>push</code>.
|
||||
testString: 'assert(code.match(/myArray.push/), ''You should be using the array method <code>push</code>.'');'
|
||||
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
|
||||
- text: '<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.'
|
||||
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], ''<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.'');'
|
||||
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,19 +25,19 @@ You will write a card counting function. It will receive a <code>card</code> par
|
||||
```yml
|
||||
tests:
|
||||
- text: 'Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), ''Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
|
||||
- text: 'Cards Sequence 7, 8, 9 should return <code>0 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), ''Cards Sequence 7, 8, 9 should return <code>0 Hold</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
|
||||
- text: 'Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(10);cc(''J'');cc(''Q'');cc(''K'');var out = cc(''A''); if(out === "-5 Hold") {return true;} return false; })(), ''Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
|
||||
- text: 'Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc(''Q'');cc(8);var out = cc(''A''); if(out === "-1 Hold") {return true;} return false; })(), ''Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
|
||||
- text: 'Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(''J'');cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), ''Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
|
||||
- text: 'Cards Sequence 2, 2, 10 should return <code>1 Bet</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), ''Cards Sequence 2, 2, 10 should return <code>1 Bet</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
|
||||
- text: 'Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc(''A'');cc(10);var out = cc(''K''); if(out === "-1 Hold") {return true;} return false; })(), ''Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>'');'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
|
||||
|
||||
```
|
||||
|
||||
@@ -53,8 +53,8 @@ var count = 0;
|
||||
|
||||
function cc(card) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
|
@@ -21,9 +21,9 @@ Create a variable <code>myDecimal</code> and give it a decimal value with a frac
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myDecimal</code> should be a number.
|
||||
testString: 'assert(typeof myDecimal === "number", ''<code>myDecimal</code> should be a number.'');'
|
||||
testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
|
||||
- text: <code>myDecimal</code> should have a decimal point
|
||||
testString: 'assert(myDecimal % 1 != 0, ''<code>myDecimal</code> should have a decimal point''); '
|
||||
testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '
|
||||
|
||||
```
|
||||
|
||||
|
@@ -28,7 +28,7 @@ Use the <code>var</code> keyword to create a variable called <code>myName</code>
|
||||
```yml
|
||||
tests:
|
||||
- text: 'You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon'
|
||||
testString: 'assert(/var\s+myName\s*;/.test(code), ''You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon'');'
|
||||
testString: 'assert(/var\s+myName\s*;/.test(code), "You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,9 +22,9 @@ Create two new <code>string</code> variables: <code>myFirstName</code> and <code
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myFirstName</code> should be a string with at least one character in it.
|
||||
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), ''<code>myFirstName</code> should be a string with at least one character in it.'');'
|
||||
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), "<code>myFirstName</code> should be a string with at least one character in it.");'
|
||||
- text: <code>myLastName</code> should be a string with at least one character in it.
|
||||
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), ''<code>myLastName</code> should be a string with at least one character in it.'');'
|
||||
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), "<code>myLastName</code> should be a string with at least one character in it.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,13 +24,13 @@ Change the code to use the <code>--</code> operator on <code>myVar</code>.
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myVar</code> should equal <code>10</code>
|
||||
testString: 'assert(myVar === 10, ''<code>myVar</code> should equal <code>10</code>'');'
|
||||
testString: 'assert(myVar === 10, "<code>myVar</code> should equal <code>10</code>");'
|
||||
- text: <code>myVar = myVar - 1;</code> should be changed
|
||||
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), ''<code>myVar = myVar - 1;</code> should be changed'');'
|
||||
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), "<code>myVar = myVar - 1;</code> should be changed");'
|
||||
- text: Use the <code>--</code> operator on <code>myVar</code>
|
||||
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), ''Use the <code>--</code> operator on <code>myVar</code>'');'
|
||||
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), "Use the <code>--</code> operator on <code>myVar</code>");'
|
||||
- text: Do not change code above the line
|
||||
testString: 'assert(/var myVar = 11;/.test(code), ''Do not change code above the line'');'
|
||||
testString: 'assert(/var myVar = 11;/.test(code), "Do not change code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -21,9 +21,9 @@ Delete the <code>"tails"</code> property from <code>myDog</code>. You may use ei
|
||||
```yml
|
||||
tests:
|
||||
- text: Delete the property <code>"tails"</code> from <code>myDog</code>.
|
||||
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, ''Delete the property <code>"tails"</code> from <code>myDog</code>.'');'
|
||||
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, "Delete the property <code>"tails"</code> from <code>myDog</code>.");'
|
||||
- text: Do not modify the <code>myDog</code> setup
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1, ''Do not modify the <code>myDog</code> setup'');'
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1, "Do not modify the <code>myDog</code> setup");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -20,11 +20,11 @@ Change the <code>0.0</code> so that <code>quotient</code> will equal to <code>2.
|
||||
```yml
|
||||
tests:
|
||||
- text: The variable <code>quotient</code> should equal <code>2.2</code>
|
||||
testString: 'assert(quotient === 2.2, ''The variable <code>quotient</code> should equal <code>2.2</code>'');'
|
||||
testString: 'assert(quotient === 2.2, "The variable <code>quotient</code> should equal <code>2.2</code>");'
|
||||
- text: You should use the <code>/</code> operator to divide 4.4 by 2
|
||||
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), ''You should use the <code>/</code> operator to divide 4.4 by 2'');'
|
||||
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), "You should use the <code>/</code> operator to divide 4.4 by 2");'
|
||||
- text: The quotient variable should only be assigned once
|
||||
testString: 'assert(code.match(/quotient/g).length === 1, ''The quotient variable should only be assigned once'');'
|
||||
testString: 'assert(code.match(/quotient/g).length === 1, "The quotient variable should only be assigned once");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,9 +25,9 @@ Change the <code>0</code> so that the <code>quotient</code> is equal to <code>2<
|
||||
```yml
|
||||
tests:
|
||||
- text: Make the variable <code>quotient</code> equal to 2.
|
||||
testString: 'assert(quotient === 2, ''Make the variable <code>quotient</code> equal to 2.'');'
|
||||
testString: 'assert(quotient === 2, "Make the variable <code>quotient</code> equal to 2.");'
|
||||
- text: Use the <code>/</code> operator
|
||||
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), ''Use the <code>/</code> operator'');'
|
||||
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), "Use the <code>/</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -26,17 +26,17 @@ Here is the text with the escape sequences written out.
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code> should not contain any spaces
|
||||
testString: 'assert(!/ /.test(myStr), ''<code>myStr</code> should not contain any spaces'');'
|
||||
testString: 'assert(!/ /.test(myStr), "<code>myStr</code> should not contain any spaces");'
|
||||
- text: '<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)'
|
||||
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), ''<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)'');'
|
||||
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), "<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)");'
|
||||
- text: <code>FirstLine</code> should be followed by the newline character <code>\n</code>
|
||||
testString: 'assert(/FirstLine\n/.test(myStr), ''<code>FirstLine</code> should be followed by the newline character <code>\n</code>'');'
|
||||
testString: 'assert(/FirstLine\n/.test(myStr), "<code>FirstLine</code> should be followed by the newline character <code>\n</code>");'
|
||||
- text: <code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character
|
||||
testString: 'assert(/\n\t/.test(myStr), ''<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character'');'
|
||||
testString: 'assert(/\n\t/.test(myStr), "<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character");'
|
||||
- text: <code>SecondLine</code> should be preceded by the backslash character <code>\\</code>
|
||||
testString: 'assert(/\SecondLine/.test(myStr), ''<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>'');'
|
||||
testString: 'assert(/\SecondLine/.test(myStr), "<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>");'
|
||||
- text: There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>
|
||||
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), ''There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>'');'
|
||||
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), "There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,9 +25,9 @@ Use <dfn>backslashes</dfn> to assign a string to the <code>myStr</code> variable
|
||||
```yml
|
||||
tests:
|
||||
- text: 'You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).'
|
||||
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, ''You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).'');'
|
||||
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).");'
|
||||
- text: 'Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>'
|
||||
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", ''Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>'');'
|
||||
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,9 +22,9 @@ Use the <code>.length</code> property to count the number of characters in the <
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>lastNameLength</code> should be equal to eight.
|
||||
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), ''<code>lastNameLength</code> should be equal to eight.'');'
|
||||
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), "<code>lastNameLength</code> should be equal to eight.");'
|
||||
- text: 'You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.'
|
||||
testString: 'assert((function(){if(code.match(/\.length/gi) && code.match(/\.length/gi).length >= 2 && code.match(/var lastNameLength \= 0;/gi) && code.match(/var lastNameLength \= 0;/gi).length >= 1){return true;}else{return false;}})(), ''You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.'');'
|
||||
testString: 'assert((function(){if(code.match(/\.length/gi) && code.match(/\.length/gi).length >= 2 && code.match(/var lastNameLength \= 0;/gi) && code.match(/var lastNameLength \= 0;/gi).length >= 1){return true;}else{return false;}})(), "You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,11 +25,11 @@ Set <code>remainder</code> equal to the remainder of <code>11</code> divided by
|
||||
```yml
|
||||
tests:
|
||||
- text: The variable <code>remainder</code> should be initialized
|
||||
testString: 'assert(/var\s+?remainder/.test(code), ''The variable <code>remainder</code> should be initialized'');'
|
||||
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
|
||||
- text: The value of <code>remainder</code> should be <code>2</code>
|
||||
testString: 'assert(remainder === 2, ''The value of <code>remainder</code> should be <code>2</code>'');'
|
||||
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
|
||||
- text: You should use the <code>%</code> operator
|
||||
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), ''You should use the <code>%</code> operator'');'
|
||||
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,11 +22,11 @@ Change <code>randomFraction</code> to return a random number instead of returnin
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>randomFraction</code> should return a random number.
|
||||
testString: 'assert(typeof randomFraction() === "number", ''<code>randomFraction</code> should return a random number.'');'
|
||||
testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
|
||||
- text: The number returned by <code>randomFraction</code> should be a decimal.
|
||||
testString: 'assert((randomFraction()+''''). match(/\./g), ''The number returned by <code>randomFraction</code> should be a decimal.'');'
|
||||
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
|
||||
- text: You should be using <code>Math.random</code> to generate the random decimal number.
|
||||
testString: 'assert(code.match(/Math\.random/g).length >= 0, ''You should be using <code>Math.random</code> to generate the random decimal number.'');'
|
||||
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -25,13 +25,13 @@ Use this technique to generate and return a random whole number between <code>0<
|
||||
```yml
|
||||
tests:
|
||||
- text: The result of <code>randomWholeNum</code> should be a whole number.
|
||||
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), ''The result of <code>randomWholeNum</code> should be a whole number.'');'
|
||||
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of <code>randomWholeNum</code> should be a whole number.");'
|
||||
- text: You should be using <code>Math.random</code> to generate a random number.
|
||||
testString: 'assert(code.match(/Math.random/g).length > 1, ''You should be using <code>Math.random</code> to generate a random number.'');'
|
||||
testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using <code>Math.random</code> to generate a random number.");'
|
||||
- text: You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.
|
||||
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), ''You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.'');'
|
||||
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), "You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.");'
|
||||
- text: You should use <code>Math.floor</code> to remove the decimal part of the number.
|
||||
testString: 'assert(code.match(/Math.floor/g).length > 1, ''You should use <code>Math.floor</code> to remove the decimal part of the number.'');'
|
||||
testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use <code>Math.floor</code> to remove the decimal part of the number.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,13 +23,13 @@ Create a function called <code>randomRange</code> that takes a range <code>myMin
|
||||
```yml
|
||||
tests:
|
||||
- text: 'The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.'
|
||||
testString: 'assert(calcMin === 5, ''The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.'');'
|
||||
testString: 'assert(calcMin === 5, "The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.");'
|
||||
- text: 'The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.'
|
||||
testString: 'assert(calcMax === 15, ''The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.'');'
|
||||
testString: 'assert(calcMax === 15, "The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.");'
|
||||
- text: 'The random number generated by <code>randomRange</code> should be an integer, not a decimal.'
|
||||
testString: 'assert(randomRange(0,1) % 1 === 0 , ''The random number generated by <code>randomRange</code> should be an integer, not a decimal.'');'
|
||||
testString: 'assert(randomRange(0,1) % 1 === 0 , "The random number generated by <code>randomRange</code> should be an integer, not a decimal.");'
|
||||
- text: '<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.'
|
||||
testString: 'assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), ''<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.'');'
|
||||
testString: 'assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), "<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,13 +22,13 @@ Inside function <code>fun1</code>, assign <code>5</code> to <code>oopsGlobal</co
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myGlobal</code> should be defined
|
||||
testString: 'assert(typeof myGlobal != "undefined", ''<code>myGlobal</code> should be defined'');'
|
||||
testString: 'assert(typeof myGlobal != "undefined", "<code>myGlobal</code> should be defined");'
|
||||
- text: <code>myGlobal</code> should have a value of <code>10</code>
|
||||
testString: 'assert(myGlobal === 10, ''<code>myGlobal</code> should have a value of <code>10</code>'');'
|
||||
testString: 'assert(myGlobal === 10, "<code>myGlobal</code> should have a value of <code>10</code>");'
|
||||
- text: <code>myGlobal</code> should be declared using the <code>var</code> keyword
|
||||
testString: 'assert(/var\s+myGlobal/.test(code), ''<code>myGlobal</code> should be declared using the <code>var</code> keyword'');'
|
||||
testString: 'assert(/var\s+myGlobal/.test(code), "<code>myGlobal</code> should be declared using the <code>var</code> keyword");'
|
||||
- text: <code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>
|
||||
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, ''<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>'');'
|
||||
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, "<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>");'
|
||||
|
||||
```
|
||||
|
||||
@@ -45,7 +45,7 @@ tests:
|
||||
|
||||
function fun1() {
|
||||
// Assign 5 to oopsGlobal Here
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Only change code above this line
|
||||
|
@@ -23,11 +23,11 @@ Add a local variable to <code>myOutfit</code> function to override the value of
|
||||
```yml
|
||||
tests:
|
||||
- text: Do not change the value of the global <code>outerWear</code>
|
||||
testString: 'assert(outerWear === "T-Shirt", ''Do not change the value of the global <code>outerWear</code>'');'
|
||||
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
|
||||
- text: <code>myOutfit</code> should return <code>"sweater"</code>
|
||||
testString: 'assert(myOutfit() === "sweater", ''<code>myOutfit</code> should return <code>"sweater"</code>'');'
|
||||
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
|
||||
- text: Do not change the return statement
|
||||
testString: 'assert(/return outerWear/.test(code), ''Do not change the return statement'');'
|
||||
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
|
||||
|
||||
```
|
||||
|
||||
@@ -44,9 +44,9 @@ var outerWear = "T-Shirt";
|
||||
|
||||
function myOutfit() {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return outerWear;
|
||||
}
|
||||
|
@@ -23,27 +23,27 @@ Your function will be passed <code>par</code> and <code>strokes</code> arguments
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>golfScore(4, 1)</code> should return "Hole-in-one!"'
|
||||
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", ''<code>golfScore(4, 1)</code> should return "Hole-in-one!"'');'
|
||||
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "<code>golfScore(4, 1)</code> should return "Hole-in-one!"");'
|
||||
- text: '<code>golfScore(4, 2)</code> should return "Eagle"'
|
||||
testString: 'assert(golfScore(4, 2) === "Eagle", ''<code>golfScore(4, 2)</code> should return "Eagle"'');'
|
||||
testString: 'assert(golfScore(4, 2) === "Eagle", "<code>golfScore(4, 2)</code> should return "Eagle"");'
|
||||
- text: '<code>golfScore(5, 2)</code> should return "Eagle"'
|
||||
testString: 'assert(golfScore(5, 2) === "Eagle", ''<code>golfScore(5, 2)</code> should return "Eagle"'');'
|
||||
testString: 'assert(golfScore(5, 2) === "Eagle", "<code>golfScore(5, 2)</code> should return "Eagle"");'
|
||||
- text: '<code>golfScore(4, 3)</code> should return "Birdie"'
|
||||
testString: 'assert(golfScore(4, 3) === "Birdie", ''<code>golfScore(4, 3)</code> should return "Birdie"'');'
|
||||
testString: 'assert(golfScore(4, 3) === "Birdie", "<code>golfScore(4, 3)</code> should return "Birdie"");'
|
||||
- text: '<code>golfScore(4, 4)</code> should return "Par"'
|
||||
testString: 'assert(golfScore(4, 4) === "Par", ''<code>golfScore(4, 4)</code> should return "Par"'');'
|
||||
testString: 'assert(golfScore(4, 4) === "Par", "<code>golfScore(4, 4)</code> should return "Par"");'
|
||||
- text: '<code>golfScore(1, 1)</code> should return "Hole-in-one!"'
|
||||
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", ''<code>golfScore(1, 1)</code> should return "Hole-in-one!"'');'
|
||||
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "<code>golfScore(1, 1)</code> should return "Hole-in-one!"");'
|
||||
- text: '<code>golfScore(5, 5)</code> should return "Par"'
|
||||
testString: 'assert(golfScore(5, 5) === "Par", ''<code>golfScore(5, 5)</code> should return "Par"'');'
|
||||
testString: 'assert(golfScore(5, 5) === "Par", "<code>golfScore(5, 5)</code> should return "Par"");'
|
||||
- text: '<code>golfScore(4, 5)</code> should return "Bogey"'
|
||||
testString: 'assert(golfScore(4, 5) === "Bogey", ''<code>golfScore(4, 5)</code> should return "Bogey"'');'
|
||||
testString: 'assert(golfScore(4, 5) === "Bogey", "<code>golfScore(4, 5)</code> should return "Bogey"");'
|
||||
- text: '<code>golfScore(4, 6)</code> should return "Double Bogey"'
|
||||
testString: 'assert(golfScore(4, 6) === "Double Bogey", ''<code>golfScore(4, 6)</code> should return "Double Bogey"'');'
|
||||
testString: 'assert(golfScore(4, 6) === "Double Bogey", "<code>golfScore(4, 6)</code> should return "Double Bogey"");'
|
||||
- text: '<code>golfScore(4, 7)</code> should return "Go Home!"'
|
||||
testString: 'assert(golfScore(4, 7) === "Go Home!", ''<code>golfScore(4, 7)</code> should return "Go Home!"'');'
|
||||
testString: 'assert(golfScore(4, 7) === "Go Home!", "<code>golfScore(4, 7)</code> should return "Go Home!"");'
|
||||
- text: '<code>golfScore(5, 9)</code> should return "Go Home!"'
|
||||
testString: 'assert(golfScore(5, 9) === "Go Home!", ''<code>golfScore(5, 9)</code> should return "Go Home!"'');'
|
||||
testString: 'assert(golfScore(5, 9) === "Go Home!", "<code>golfScore(5, 9)</code> should return "Go Home!"");'
|
||||
|
||||
```
|
||||
|
||||
@@ -58,8 +58,8 @@ tests:
|
||||
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
|
||||
function golfScore(par, strokes) {
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
|
||||
|
||||
return "Change Me";
|
||||
// Only change code above this line
|
||||
}
|
||||
@@ -83,27 +83,27 @@ function golfScore(par, strokes) {
|
||||
if (strokes === 1) {
|
||||
return "Hole-in-one!";
|
||||
}
|
||||
|
||||
|
||||
if (strokes <= par - 2) {
|
||||
return "Eagle";
|
||||
}
|
||||
|
||||
|
||||
if (strokes === par - 1) {
|
||||
return "Birdie";
|
||||
}
|
||||
|
||||
|
||||
if (strokes === par) {
|
||||
return "Par";
|
||||
}
|
||||
|
||||
|
||||
if (strokes === par + 1) {
|
||||
return "Bogey";
|
||||
}
|
||||
|
||||
|
||||
if(strokes === par + 2) {
|
||||
return "Double Bogey";
|
||||
}
|
||||
|
||||
|
||||
return "Go Home!";
|
||||
}
|
||||
```
|
||||
|
@@ -25,13 +25,13 @@ Change the code to use the <code>++</code> operator on <code>myVar</code>.
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myVar</code> should equal <code>88</code>
|
||||
testString: 'assert(myVar === 88, ''<code>myVar</code> should equal <code>88</code>'');'
|
||||
testString: 'assert(myVar === 88, "<code>myVar</code> should equal <code>88</code>");'
|
||||
- text: <code>myVar = myVar + 1;</code> should be changed
|
||||
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), ''<code>myVar = myVar + 1;</code> should be changed'');'
|
||||
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), "<code>myVar = myVar + 1;</code> should be changed");'
|
||||
- text: Use the <code>++</code> operator
|
||||
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), ''Use the <code>++</code> operator'');'
|
||||
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), "Use the <code>++</code> operator");'
|
||||
- text: Do not change code above the line
|
||||
testString: 'assert(/var myVar = 87;/.test(code), ''Do not change code above the line'');'
|
||||
testString: 'assert(/var myVar = 87;/.test(code), "Do not change code above the line");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,7 +22,7 @@ Define a variable <code>a</code> with <code>var</code> and initialize it to a va
|
||||
```yml
|
||||
tests:
|
||||
- text: Initialize <code>a</code> to a value of <code>9</code>
|
||||
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), ''Initialize <code>a</code> to a value of <code>9</code>'');'
|
||||
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), "Initialize <code>a</code> to a value of <code>9</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -21,21 +21,21 @@ Convert the logic to use <code>else if</code> statements.
|
||||
```yml
|
||||
tests:
|
||||
- text: You should have at least two <code>else</code> statements
|
||||
testString: 'assert(code.match(/else/g).length > 1, ''You should have at least two <code>else</code> statements'');'
|
||||
testString: 'assert(code.match(/else/g).length > 1, "You should have at least two <code>else</code> statements");'
|
||||
- text: You should have at least two <code>if</code> statements
|
||||
testString: 'assert(code.match(/if/g).length > 1, ''You should have at least two <code>if</code> statements'');'
|
||||
testString: 'assert(code.match(/if/g).length > 1, "You should have at least two <code>if</code> statements");'
|
||||
- text: You should have closing and opening curly braces for each condition
|
||||
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), ''You should have closing and opening curly braces for each condition in your if else statement'');'
|
||||
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), "You should have closing and opening curly braces for each condition in your if else statement");'
|
||||
- text: <code>testElseIf(0)</code> should return "Smaller than 5"
|
||||
testString: 'assert(testElseIf(0) === "Smaller than 5", ''<code>testElseIf(0)</code> should return "Smaller than 5"'');'
|
||||
testString: 'assert(testElseIf(0) === "Smaller than 5", "<code>testElseIf(0)</code> should return "Smaller than 5"");'
|
||||
- text: <code>testElseIf(5)</code> should return "Between 5 and 10"
|
||||
testString: 'assert(testElseIf(5) === "Between 5 and 10", ''<code>testElseIf(5)</code> should return "Between 5 and 10"'');'
|
||||
testString: 'assert(testElseIf(5) === "Between 5 and 10", "<code>testElseIf(5)</code> should return "Between 5 and 10"");'
|
||||
- text: <code>testElseIf(7)</code> should return "Between 5 and 10"
|
||||
testString: 'assert(testElseIf(7) === "Between 5 and 10", ''<code>testElseIf(7)</code> should return "Between 5 and 10"'');'
|
||||
testString: 'assert(testElseIf(7) === "Between 5 and 10", "<code>testElseIf(7)</code> should return "Between 5 and 10"");'
|
||||
- text: <code>testElseIf(10)</code> should return "Between 5 and 10"
|
||||
testString: 'assert(testElseIf(10) === "Between 5 and 10", ''<code>testElseIf(10)</code> should return "Between 5 and 10"'');'
|
||||
testString: 'assert(testElseIf(10) === "Between 5 and 10", "<code>testElseIf(10)</code> should return "Between 5 and 10"");'
|
||||
- text: <code>testElseIf(12)</code> should return "Greater than 10"
|
||||
testString: 'assert(testElseIf(12) === "Greater than 10", ''<code>testElseIf(12)</code> should return "Greater than 10"'');'
|
||||
testString: 'assert(testElseIf(12) === "Greater than 10", "<code>testElseIf(12)</code> should return "Greater than 10"");'
|
||||
|
||||
```
|
||||
|
||||
@@ -51,11 +51,11 @@ function testElseIf(val) {
|
||||
if (val > 10) {
|
||||
return "Greater than 10";
|
||||
}
|
||||
|
||||
|
||||
if (val < 5) {
|
||||
return "Smaller than 5";
|
||||
}
|
||||
|
||||
|
||||
return "Between 5 and 10";
|
||||
}
|
||||
|
||||
|
@@ -21,19 +21,19 @@ Combine the <code>if</code> statements into a single <code>if/else</code> statem
|
||||
```yml
|
||||
tests:
|
||||
- text: You should only have one <code>if</code> statement in the editor
|
||||
testString: 'assert(code.match(/if/g).length === 1, ''You should only have one <code>if</code> statement in the editor'');'
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement in the editor");'
|
||||
- text: You should use an <code>else</code> statement
|
||||
testString: 'assert(/else/g.test(code), ''You should use an <code>else</code> statement'');'
|
||||
testString: 'assert(/else/g.test(code), "You should use an <code>else</code> statement");'
|
||||
- text: <code>testElse(4)</code> should return "5 or Smaller"
|
||||
testString: 'assert(testElse(4) === "5 or Smaller", ''<code>testElse(4)</code> should return "5 or Smaller"'');'
|
||||
testString: 'assert(testElse(4) === "5 or Smaller", "<code>testElse(4)</code> should return "5 or Smaller"");'
|
||||
- text: <code>testElse(5)</code> should return "5 or Smaller"
|
||||
testString: 'assert(testElse(5) === "5 or Smaller", ''<code>testElse(5)</code> should return "5 or Smaller"'');'
|
||||
testString: 'assert(testElse(5) === "5 or Smaller", "<code>testElse(5)</code> should return "5 or Smaller"");'
|
||||
- text: <code>testElse(6)</code> should return "Bigger than 5"
|
||||
testString: 'assert(testElse(6) === "Bigger than 5", ''<code>testElse(6)</code> should return "Bigger than 5"'');'
|
||||
testString: 'assert(testElse(6) === "Bigger than 5", "<code>testElse(6)</code> should return "Bigger than 5"");'
|
||||
- text: <code>testElse(10)</code> should return "Bigger than 5"
|
||||
testString: 'assert(testElse(10) === "Bigger than 5", ''<code>testElse(10)</code> should return "Bigger than 5"'');'
|
||||
testString: 'assert(testElse(10) === "Bigger than 5", "<code>testElse(10)</code> should return "Bigger than 5"");'
|
||||
- text: Do not change the code above or below the lines.
|
||||
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), ''Do not change the code above or below the lines.'');'
|
||||
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), "Do not change the code above or below the lines.");'
|
||||
|
||||
```
|
||||
|
||||
@@ -48,15 +48,15 @@ tests:
|
||||
function testElse(val) {
|
||||
var result = "";
|
||||
// Only change code below this line
|
||||
|
||||
|
||||
if (val > 5) {
|
||||
result = "Bigger than 5";
|
||||
}
|
||||
|
||||
|
||||
if (val <= 5) {
|
||||
result = "5 or Smaller";
|
||||
}
|
||||
|
||||
|
||||
// Only change code above this line
|
||||
return result;
|
||||
}
|
||||
|
@@ -24,9 +24,9 @@ Push the odd numbers from 1 through 9 to <code>myArray</code> using a <code>for<
|
||||
```yml
|
||||
tests:
|
||||
- text: You should be using a <code>for</code> loop for this.
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: '<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.'
|
||||
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], ''<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.'');'
|
||||
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], "<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -22,13 +22,13 @@ Declare and initialize a variable <code>total</code> to <code>0</code>. Use a <c
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>total</code> should be declared and initialized to 0
|
||||
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), ''<code>total</code> should be declared and initialized to 0'');'
|
||||
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), "<code>total</code> should be declared and initialized to 0");'
|
||||
- text: <code>total</code> should equal 20
|
||||
testString: 'assert(total === 20, ''<code>total</code> should equal 20'');'
|
||||
testString: 'assert(total === 20, "<code>total</code> should equal 20");'
|
||||
- text: You should use a <code>for</code> loop to iterate through <code>myArr</code>
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), ''You should use a <code>for</code> loop to iterate through <code>myArr</code>'');'
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), "You should use a <code>for</code> loop to iterate through <code>myArr</code>");'
|
||||
- text: Do not set <code>total</code> to 20 directly
|
||||
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), ''Do not set <code>total</code> to 20 directly'');'
|
||||
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), "Do not set <code>total</code> to 20 directly");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -31,11 +31,11 @@ Change the <code>while</code> loop in the code to a <code>do...while</code> loop
|
||||
```yml
|
||||
tests:
|
||||
- text: You should be using a <code>do...while</code> loop for this.
|
||||
testString: 'assert(code.match(/do/g), ''You should be using a <code>do...while</code> loop for this.'');'
|
||||
testString: 'assert(code.match(/do/g), "You should be using a <code>do...while</code> loop for this.");'
|
||||
- text: '<code>myArray</code> should equal <code>[10]</code>.'
|
||||
testString: 'assert.deepEqual(myArray, [10], ''<code>myArray</code> should equal <code>[10]</code>.'');'
|
||||
testString: 'assert.deepEqual(myArray, [10], "<code>myArray</code> should equal <code>[10]</code>.");'
|
||||
- text: <code>i</code> should equal <code>11</code>
|
||||
testString: 'assert.deepEqual(i, 11, ''<code>i</code> should equal <code>11</code>'');'
|
||||
testString: 'assert.deepEqual(i, 11, "<code>i</code> should equal <code>11</code>");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -29,9 +29,9 @@ Use a <code>for</code> loop to work to push the values 1 through 5 onto <code>my
|
||||
```yml
|
||||
tests:
|
||||
- text: You should be using a <code>for</code> loop for this.
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, ''You should be using a <code>for</code> loop for this.'');'
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
- text: '<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.'
|
||||
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], ''<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.'');'
|
||||
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], "<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -23,9 +23,9 @@ Push the numbers 0 through 4 to <code>myArray</code> using a <code>while</code>
|
||||
```yml
|
||||
tests:
|
||||
- text: You should be using a <code>while</code> loop for this.
|
||||
testString: 'assert(code.match(/while/g), ''You should be using a <code>while</code> loop for this.'');'
|
||||
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
|
||||
- text: '<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.'
|
||||
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], ''<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.'');'
|
||||
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
|
@@ -24,9 +24,9 @@ Declare a local variable <code>myVar</code> inside <code>myLocalScope</code>. Ru
|
||||
```yml
|
||||
tests:
|
||||
- text: No global <code>myVar</code> variable
|
||||
testString: 'assert(typeof myVar === ''undefined'', ''No global <code>myVar</code> variable'');'
|
||||
testString: 'assert(typeof myVar === "undefined", "No global <code>myVar</code> variable");'
|
||||
- text: Add a local <code>myVar</code> variable
|
||||
testString: 'assert(/var\s+myVar/.test(code), ''Add a local <code>myVar</code> variable'');'
|
||||
testString: 'assert(/var\s+myVar/.test(code), "Add a local <code>myVar</code> variable");'
|
||||
|
||||
```
|
||||
|
||||
@@ -40,7 +40,7 @@ tests:
|
||||
```js
|
||||
function myLocalScope() {
|
||||
'use strict'; // you shouldn't need to edit this line
|
||||
|
||||
|
||||
console.log(myVar);
|
||||
}
|
||||
myLocalScope();
|
||||
@@ -100,7 +100,7 @@ console.info('after the test');
|
||||
```js
|
||||
function myLocalScope() {
|
||||
'use strict';
|
||||
|
||||
|
||||
var myVar;
|
||||
console.log(myVar);
|
||||
}
|
||||
|
@@ -28,11 +28,11 @@ Change the order of logic in the function so that it will return the correct sta
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>orderMyLogic(4)</code> should return "Less than 5"
|
||||
testString: 'assert(orderMyLogic(4) === "Less than 5", ''<code>orderMyLogic(4)</code> should return "Less than 5"'');'
|
||||
testString: 'assert(orderMyLogic(4) === "Less than 5", "<code>orderMyLogic(4)</code> should return "Less than 5"");'
|
||||
- text: <code>orderMyLogic(6)</code> should return "Less than 10"
|
||||
testString: 'assert(orderMyLogic(6) === "Less than 10", ''<code>orderMyLogic(6)</code> should return "Less than 10"'');'
|
||||
testString: 'assert(orderMyLogic(6) === "Less than 10", "<code>orderMyLogic(6)</code> should return "Less than 10"");'
|
||||
- text: <code>orderMyLogic(11)</code> should return "Greater than or equal to 10"
|
||||
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", ''<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"'');'
|
||||
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", "<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"");'
|
||||
|
||||
```
|
||||
|
||||
@@ -71,7 +71,7 @@ orderMyLogic(7);
|
||||
```js
|
||||
function orderMyLogic(val) {
|
||||
if(val < 5) {
|
||||
return "Less than 5";
|
||||
return "Less than 5";
|
||||
} else if (val < 10) {
|
||||
return "Less than 10";
|
||||
} else {
|
||||
|
@@ -23,11 +23,11 @@ Use the <code>.pop()</code> function to remove the last item from <code>myArray<
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code> should only contain <code>[["John", 23]]</code>.'
|
||||
testString: 'assert((function(d){if(d[0][0] == ''John'' && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), ''<code>myArray</code> should only contain <code>[["John", 23]]</code>.'');'
|
||||
testString: 'assert((function(d){if(d[0][0] == "John" && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should only contain <code>[["John", 23]]</code>.");'
|
||||
- text: Use <code>pop()</code> on <code>myArray</code>
|
||||
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), ''Use <code>pop()</code> on <code>myArray</code>'');'
|
||||
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), "Use <code>pop()</code> on <code>myArray</code>");'
|
||||
- text: '<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.'
|
||||
testString: 'assert((function(d){if(d[0] == ''cat'' && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), ''<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.'');'
|
||||
testString: 'assert((function(d){if(d[0] == "cat" && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
@@ -41,7 +41,7 @@ tests:
|
||||
```js
|
||||
// Example
|
||||
var ourArray = [1,2,3];
|
||||
var removedFromOurArray = ourArray.pop();
|
||||
var removedFromOurArray = ourArray.pop();
|
||||
// removedFromOurArray now equals 3, and ourArray now equals [1,2]
|
||||
|
||||
// Setup
|
||||
|
@@ -22,7 +22,7 @@ Push <code>["dog", 3]</code> onto the end of the <code>myArray</code> variable.
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.'
|
||||
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == ''John'' && d[0][1] === 23 && d[2][0] == ''dog'' && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), ''<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.'');'
|
||||
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == "John" && d[0][1] === 23 && d[2][0] == "dog" && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.");'
|
||||
|
||||
```
|
||||
|
||||
@@ -36,7 +36,7 @@ tests:
|
||||
```js
|
||||
// Example
|
||||
var ourArray = ["Stimpson", "J", "cat"];
|
||||
ourArray.push(["happy", "joy"]);
|
||||
ourArray.push(["happy", "joy"]);
|
||||
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
|
||||
|
||||
// Setup
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user