fix(curriculum): quotes in tests (#18828)

* fix(curriculum): tests quotes

* fix(curriculum): fill seed-teardown

* fix(curriculum): fix tests and remove unneeded seed-teardown
This commit is contained in:
Valeriy
2018-10-20 21:02:47 +03:00
committed by mrugesh mohapatra
parent 96eb124163
commit 79d9012432
1339 changed files with 6499 additions and 5185 deletions

View File

@ -23,15 +23,15 @@ Change the <code>nonMutatingPush</code> function so it uses <code>concat</code>
```yml
tests:
- text: Your code should use the <code>concat</code> method.
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
testString: assert(code.match(/\.concat/g), 'Your code should use the <code>concat</code> method.');
- text: Your code should not use the <code>push</code> method.
testString: 'assert(!code.match(/\.push/g), "Your code should not use the <code>push</code> method.");'
testString: assert(!code.match(/\.push/g), 'Your code should not use the <code>push</code> method.');
- text: The <code>first</code> array should not change.
testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The <code>first</code> array should not change.");'
testString: assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The <code>first</code> array should not change.');
- text: The <code>second</code> array should not change.
testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The <code>second</code> array should not change.");'
- text: '<code>nonMutatingPush([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.'
testString: 'assert(JSON.stringify(nonMutatingPush([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), "<code>nonMutatingPush([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.");'
testString: assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The <code>second</code> array should not change.');
- text: <code>nonMutatingPush([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.
testString: assert(JSON.stringify(nonMutatingPush([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), '<code>nonMutatingPush([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.');
```

View File

@ -26,17 +26,17 @@ The output should not have any spaces
```yml
tests:
- text: The <code>globalTitle</code> variable should not change.
testString: 'assert(globalTitle === "Winter Is Coming", "The <code>globalTitle</code> variable should not change.");'
testString: assert(globalTitle === "Winter Is Coming", 'The <code>globalTitle</code> variable should not change.');
- text: Your code should not use the <code>replace</code> method for this challenge.
testString: 'assert(!code.match(/\.replace/g), "Your code should not use the <code>replace</code> method for this challenge.");'
testString: assert(!code.match(/\.replace/g), 'Your code should not use the <code>replace</code> method for this challenge.');
- text: <code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.
testString: 'assert(urlSlug("Winter Is Coming") === "winter-is-coming", "<code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.");'
testString: assert(urlSlug("Winter Is Coming") === "winter-is-coming", '<code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.');
- text: <code>urlSlug(" Winter Is &nbsp;Coming")</code> should return <code>"winter-is-coming"</code>.
testString: 'assert(urlSlug(" Winter Is Coming") === "winter-is-coming", "<code>urlSlug(" Winter Is &nbsp;Coming")</code> should return <code>"winter-is-coming"</code>.");'
testString: assert(urlSlug(" Winter Is Coming") === "winter-is-coming", '<code>urlSlug(" Winter Is &nbsp;Coming")</code> should return <code>"winter-is-coming"</code>.');
- text: <code>urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone")</code> should return <code>"a-mind-needs-books-like-a-sword-needs-a-whetstone"</code>.
testString: 'assert(urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone") === "a-mind-needs-books-like-a-sword-needs-a-whetstone", "<code>urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone")</code> should return <code>"a-mind-needs-books-like-a-sword-needs-a-whetstone"</code>.");'
testString: assert(urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone") === "a-mind-needs-books-like-a-sword-needs-a-whetstone", '<code>urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone")</code> should return <code>"a-mind-needs-books-like-a-sword-needs-a-whetstone"</code>.');
- text: <code>urlSlug("Hold The Door")</code> should return <code>"hold-the-door"</code>.
testString: 'assert(urlSlug("Hold The Door") === "hold-the-door", "<code>urlSlug("Hold The Door")</code> should return <code>"hold-the-door"</code>.");'
testString: assert(urlSlug("Hold The Door") === "hold-the-door", '<code>urlSlug("Hold The Door")</code> should return <code>"hold-the-door"</code>.');
```

View File

@ -25,9 +25,9 @@ Fill in the code for the function <code>incrementer</code> so it returns the val
```yml
tests:
- text: Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.
testString: 'assert(fixedValue === 4, "Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.");'
testString: assert(fixedValue === 4, 'Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.');
- text: Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.
testString: 'assert(newValue === 5, "Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.");'
testString: assert(newValue === 5, 'Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.');
```
@ -68,5 +68,7 @@ var fixedValue = 4
function incrementer() {
return fixedValue + 1
}
var newValue = incrementer(); // Should equal 5
```
</section>

View File

@ -22,17 +22,17 @@ Use the <code>join</code> method (among others) inside the <code>sentensify</cod
```yml
tests:
- text: Your code should use the <code>join</code> method.
testString: 'assert(code.match(/\.join/g), "Your code should use the <code>join</code> method.");'
testString: assert(code.match(/\.join/g), 'Your code should use the <code>join</code> method.');
- text: Your code should not use the <code>replace</code> method.
testString: 'assert(!code.match(/\.replace/g), "Your code should not use the <code>replace</code> method.");'
testString: assert(!code.match(/\.replace/g), 'Your code should not use the <code>replace</code> method.');
- text: <code>sentensify("May-the-force-be-with-you")</code> should return a string.
testString: 'assert(typeof sentensify("May-the-force-be-with-you") === "string", "<code>sentensify("May-the-force-be-with-you")</code> should return a string.");'
testString: assert(typeof sentensify("May-the-force-be-with-you") === "string", '<code>sentensify("May-the-force-be-with-you")</code> should return a string.');
- text: <code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.
testString: 'assert(sentensify("May-the-force-be-with-you") === "May the force be with you", "<code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.");'
testString: assert(sentensify("May-the-force-be-with-you") === "May the force be with you", '<code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.');
- text: <code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.
testString: 'assert(sentensify("The.force.is.strong.with.this.one") === "The force is strong with this one", "<code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.");'
- text: '<code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.'
testString: 'assert(sentensify("There,has,been,an,awakening") === "There has been an awakening", "<code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.");'
testString: assert(sentensify("The.force.is.strong.with.this.one") === "The force is strong with this one", '<code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.');
- text: <code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.
testString: assert(sentensify("There,has,been,an,awakening") === "There has been an awakening", '<code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.');
```

View File

@ -21,13 +21,13 @@ Use the <code>concat</code> method in the <code>nonMutatingConcat</code> functio
```yml
tests:
- text: Your code should use the <code>concat</code> method.
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
testString: assert(code.match(/\.concat/g), 'Your code should use the <code>concat</code> method.');
- text: The <code>first</code> array should not change.
testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The <code>first</code> array should not change.");'
testString: assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The <code>first</code> array should not change.');
- text: The <code>second</code> array should not change.
testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The <code>second</code> array should not change.");'
- text: '<code>nonMutatingConcat([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.'
testString: 'assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), "<code>nonMutatingConcat([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.");'
testString: assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The <code>second</code> array should not change.');
- text: <code>nonMutatingConcat([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.
testString: assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), '<code>nonMutatingConcat([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.');
```

View File

@ -22,10 +22,10 @@ Write your own <code>Array.prototype.myMap()</code>, which should behave exactly
```yml
tests:
- text: '<code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.'
testString: 'assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]), "<code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.");'
- text: <code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.
testString: assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]), '<code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.');
- text: Your code should not use the <code>map</code> method.
testString: 'assert(!code.match(/\.map/g), "Your code should not use the <code>map</code> method.");'
testString: assert(!code.match(/\.map/g), 'Your code should not use the <code>map</code> method.');
```

View File

@ -20,10 +20,10 @@ Write your own <code>Array.prototype.myFilter()</code>, which should behave exac
```yml
tests:
- text: '<code>new_s</code> should equal <code>[23, 65, 5]</code>.'
testString: 'assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]), "<code>new_s</code> should equal <code>[23, 65, 5]</code>.");'
- text: <code>new_s</code> should equal <code>[23, 65, 5]</code>.
testString: assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]), '<code>new_s</code> should equal <code>[23, 65, 5]</code>.');
- text: Your code should not use the <code>filter</code> method.
testString: 'assert(!code.match(/\.filter/g), "Your code should not use the <code>filter</code> method.");'
testString: assert(!code.match(/\.filter/g), 'Your code should not use the <code>filter</code> method.');
```

View File

@ -32,13 +32,13 @@ Fill in the body of the <code>add</code> function so it uses currying to add par
```yml
tests:
- text: <code>add(10)(20)(30)</code> should return <code>60</code>.
testString: 'assert(add(10)(20)(30) === 60, "<code>add(10)(20)(30)</code> should return <code>60</code>.");'
testString: assert(add(10)(20)(30) === 60, '<code>add(10)(20)(30)</code> should return <code>60</code>.');
- text: <code>add(1)(2)(3)</code> should return <code>6</code>.
testString: 'assert(add(1)(2)(3) === 6, "<code>add(1)(2)(3)</code> should return <code>6</code>.");'
testString: assert(add(1)(2)(3) === 6, '<code>add(1)(2)(3)</code> should return <code>6</code>.');
- text: <code>add(11)(22)(33)</code> should return <code>66</code>.
testString: 'assert(add(11)(22)(33) === 66, "<code>add(11)(22)(33)</code> should return <code>66</code>.");'
testString: assert(add(11)(22)(33) === 66, '<code>add(11)(22)(33)</code> should return <code>66</code>.');
- text: Your code should include a final statement that returns <code>x + y + z</code>.
testString: 'assert(code.match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g), "Your code should include a final statement that returns <code>x + y + z</code>.");'
testString: assert(code.match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g), 'Your code should include a final statement that returns <code>x + y + z</code>.');
```

View File

@ -26,9 +26,9 @@ In the code editor, the <code>prepareTea</code> and <code>getTea</code> function
```yml
tests:
- text: The <code>tea4TeamFCC</code> variable should hold 40 cups of tea for the team.
testString: 'assert(tea4TeamFCC.length === 40, "The <code>tea4TeamFCC</code> variable should hold 40 cups of tea for the team.");'
testString: assert(tea4TeamFCC.length === 40, 'The <code>tea4TeamFCC</code> variable should hold 40 cups of tea for the team.');
- text: The <code>tea4TeamFCC</code> variable should hold cups of green tea.
testString: 'assert(tea4TeamFCC[0] === "greenTea", "The <code>tea4TeamFCC</code> variable should hold cups of green tea.");'
testString: assert(tea4TeamFCC[0] === 'greenTea', 'The <code>tea4TeamFCC</code> variable should hold cups of green tea.');
```

View File

@ -26,11 +26,11 @@ Write the <code>incrementer</code> function so it takes an argument, and then in
```yml
tests:
- text: Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.
testString: 'assert(fixedValue === 4, "Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.");'
testString: assert(fixedValue === 4, 'Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.');
- text: Your <code>incrementer</code> function should take a parameter.
testString: 'assert(code.match(/function\s+?incrementer\s*?\(.+?\)/g), "Your <code>incrementer</code> function should take a parameter.");'
testString: assert(code.match(/function\s+?incrementer\s*?\(.+?\)/g), 'Your <code>incrementer</code> function should take a parameter.');
- text: Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.
testString: 'assert(newValue === 5, "Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.");'
testString: assert(newValue === 5, 'Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.');
```

View File

@ -22,14 +22,14 @@ Refactor (rewrite) the code so the global array <code>bookList</code> is not cha
```yml
tests:
- text: '<code>bookList</code> should not change and still equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.'
testString: 'assert(JSON.stringify(bookList) === JSON.stringify(["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]), "<code>bookList</code> should not change and still equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.");'
- text: '<code>newBookList</code> should equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.'
testString: 'assert(JSON.stringify(newBookList) === JSON.stringify(["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]), "<code>newBookList</code> should equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.");'
- text: '<code>newerBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.'
testString: 'assert(JSON.stringify(newerBookList) === JSON.stringify(["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]), "<code>newerBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.");'
- text: '<code>newestBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.'
testString: 'assert(JSON.stringify(newestBookList) === JSON.stringify(["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]), "<code>newestBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.");'
- text: <code>bookList</code> should not change and still equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.
testString: assert(JSON.stringify(bookList) === JSON.stringify(["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]), '<code>bookList</code> should not change and still equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.');
- text: <code>newBookList</code> should equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.
testString: assert(JSON.stringify(newBookList) === JSON.stringify(['The Hound of the Baskervilles', 'On The Electrodynamics of Moving Bodies', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), '<code>newBookList</code> should equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.');
- text: <code>newerBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.
testString: assert(JSON.stringify(newerBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae']), '<code>newerBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.');
- text: <code>newestBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.
testString: assert(JSON.stringify(newestBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), '<code>newestBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.');
```

View File

@ -23,13 +23,13 @@ Do not mutate the original array provided to the function.
```yml
tests:
- text: Your code should use the <code>slice</code> method.
testString: 'assert(code.match(/\.slice/g), "Your code should use the <code>slice</code> method.");'
testString: assert(code.match(/\.slice/g), 'Your code should use the <code>slice</code> method.');
- text: Your code should not use the <code>splice</code> method.
testString: 'assert(!code.match(/\.splice/g), "Your code should not use the <code>splice</code> method.");'
testString: assert(!code.match(/\.splice/g), 'Your code should not use the <code>splice</code> method.');
- text: The <code>inputCities</code> array should not change.
testString: 'assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]), "The <code>inputCities</code> array should not change.");'
- text: '<code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.'
testString: 'assert(JSON.stringify(nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])) === JSON.stringify(["Chicago", "Delhi", "Islamabad"]), "<code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.");'
testString: assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]), 'The <code>inputCities</code> array should not change.');
- text: <code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.
testString: assert(JSON.stringify(nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])) === JSON.stringify(["Chicago", "Delhi", "Islamabad"]), '<code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.');
```

View File

@ -20,13 +20,13 @@ Use the <code>sort</code> method in the <code>nonMutatingSort</code> function to
```yml
tests:
- text: Your code should use the <code>sort</code> method.
testString: 'assert(code.match(/\.sort/g), "Your code should use the <code>sort</code> method.");'
testString: assert(code.match(/\.sort/g), 'Your code should use the <code>sort</code> method.');
- text: Your code should use the <code>concat</code> method.
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
testString: assert(code.match(/\.concat/g), 'Your code should use the <code>concat</code> method.');
- text: The <code>globalArray</code> variable should not change.
testString: 'assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]), "The <code>globalArray</code> variable should not change.");'
- text: '<code>nonMutatingSort(globalArray)</code> should return <code>[2, 3, 5, 6, 9]</code>.'
testString: 'assert(JSON.stringify(nonMutatingSort(globalArray)) === JSON.stringify([2, 3, 5, 6, 9]), "<code>nonMutatingSort(globalArray)</code> should return <code>[2, 3, 5, 6, 9]</code>.");'
testString: assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]), 'The <code>globalArray</code> variable should not change.');
- text: <code>nonMutatingSort(globalArray)</code> should return <code>[2, 3, 5, 6, 9]</code>.
testString: assert(JSON.stringify(nonMutatingSort(globalArray)) === JSON.stringify([2, 3, 5, 6, 9]), '<code>nonMutatingSort(globalArray)</code> should return <code>[2, 3, 5, 6, 9]</code>.');
```

View File

@ -22,15 +22,15 @@ Use the <code>slice</code> method in the <code>sliceArray</code> function to ret
```yml
tests:
- text: Your code should use the <code>slice</code> method.
testString: 'assert(code.match(/\.slice/g), "Your code should use the <code>slice</code> method.");'
testString: assert(code.match(/\.slice/g), 'Your code should use the <code>slice</code> method.');
- text: The <code>inputAnim</code> variable should not change.
testString: 'assert(JSON.stringify(inputAnim) === JSON.stringify(["Cat", "Dog", "Tiger", "Zebra", "Ant"]), "The <code>inputAnim</code> variable should not change.");'
- text: '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)</code> should return <code>["Dog", "Tiger"]</code>.'
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)) === JSON.stringify(["Dog", "Tiger"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)</code> should return <code>["Dog", "Tiger"]</code>.");'
- text: '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)</code> should return <code>["Cat"]</code>.'
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)) === JSON.stringify(["Cat"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)</code> should return <code>["Cat"]</code>.");'
- text: '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)</code> should return <code>["Dog", "Tiger", "Zebra"]</code>.'
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)) === JSON.stringify(["Dog", "Tiger", "Zebra"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)</code> should return <code>["Dog", "Tiger", "Zebra"]</code>.");'
testString: assert(JSON.stringify(inputAnim) === JSON.stringify(["Cat", "Dog", "Tiger", "Zebra", "Ant"]), 'The <code>inputAnim</code> variable should not change.');
- text: <code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)</code> should return <code>["Dog", "Tiger"]</code>.
testString: assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)) === JSON.stringify(["Dog", "Tiger"]), '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)</code> should return <code>["Dog", "Tiger"]</code>.');
- text: <code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)</code> should return <code>["Cat"]</code>.
testString: assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)) === JSON.stringify(["Cat"]), '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)</code> should return <code>["Cat"]</code>.');
- text: <code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)</code> should return <code>["Dog", "Tiger", "Zebra"]</code>.
testString: assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)) === JSON.stringify(["Dog", "Tiger", "Zebra"]), '<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)</code> should return <code>["Dog", "Tiger", "Zebra"]</code>.');
```

View File

@ -23,13 +23,13 @@ Use the <code>sort</code> method in the <code>alphabeticalOrder</code> function
```yml
tests:
- text: Your code should use the <code>sort</code> method.
testString: 'assert(code.match(/\.sort/g), "Your code should use the <code>sort</code> method.");'
- text: '<code>alphabeticalOrder(["a", "d", "c", "a", "z", "g"])</code> should return <code>["a", "a", "c", "d", "g", "z"]</code>.'
testString: 'assert(JSON.stringify(alphabeticalOrder(["a", "d", "c", "a", "z", "g"])) === JSON.stringify(["a", "a", "c", "d", "g", "z"]), "<code>alphabeticalOrder(["a", "d", "c", "a", "z", "g"])</code> should return <code>["a", "a", "c", "d", "g", "z"]</code>.");'
- text: '<code>alphabeticalOrder(["x", "h", "a", "m", "n", "m"])</code> should return <code>["a", "h", "m", "m", "n", "x"]</code>.'
testString: 'assert(JSON.stringify(alphabeticalOrder(["x", "h", "a", "m", "n", "m"])) === JSON.stringify(["a", "h", "m", "m", "n", "x"]), "<code>alphabeticalOrder(["x", "h", "a", "m", "n", "m"])</code> should return <code>["a", "h", "m", "m", "n", "x"]</code>.");'
- text: '<code>alphabeticalOrder(["a", "a", "a", "a", "x", "t"])</code> should return <code>["a", "a", "a", "a", "t", "x"]</code>.'
testString: 'assert(JSON.stringify(alphabeticalOrder(["a", "a", "a", "a", "x", "t"])) === JSON.stringify(["a", "a", "a", "a", "t", "x"]), "<code>alphabeticalOrder(["a", "a", "a", "a", "x", "t"])</code> should return <code>["a", "a", "a", "a", "t", "x"]</code>.");'
testString: assert(code.match(/\.sort/g), 'Your code should use the <code>sort</code> method.');
- text: <code>alphabeticalOrder(["a", "d", "c", "a", "z", "g"])</code> should return <code>["a", "a", "c", "d", "g", "z"]</code>.
testString: assert(JSON.stringify(alphabeticalOrder(["a", "d", "c", "a", "z", "g"])) === JSON.stringify(["a", "a", "c", "d", "g", "z"]), '<code>alphabeticalOrder(["a", "d", "c", "a", "z", "g"])</code> should return <code>["a", "a", "c", "d", "g", "z"]</code>.');
- text: <code>alphabeticalOrder(["x", "h", "a", "m", "n", "m"])</code> should return <code>["a", "h", "m", "m", "n", "x"]</code>.
testString: assert(JSON.stringify(alphabeticalOrder(["x", "h", "a", "m", "n", "m"])) === JSON.stringify(["a", "h", "m", "m", "n", "x"]), '<code>alphabeticalOrder(["x", "h", "a", "m", "n", "m"])</code> should return <code>["a", "h", "m", "m", "n", "x"]</code>.');
- text: <code>alphabeticalOrder(["a", "a", "a", "a", "x", "t"])</code> should return <code>["a", "a", "a", "a", "t", "x"]</code>.
testString: assert(JSON.stringify(alphabeticalOrder(["a", "a", "a", "a", "x", "t"])) === JSON.stringify(["a", "a", "a", "a", "t", "x"]), '<code>alphabeticalOrder(["a", "a", "a", "a", "x", "t"])</code> should return <code>["a", "a", "a", "a", "t", "x"]</code>.');
```

View File

@ -23,13 +23,13 @@ Use the <code>split</code> method inside the <code>splitify</code> function to s
```yml
tests:
- text: Your code should use the <code>split</code> method.
testString: 'assert(code.match(/\.split/g), "Your code should use the <code>split</code> method.");'
- text: '<code>splitify("Hello World,I-am code")</code> should return <code>["Hello", "World", "I", "am", "code"]</code>.'
testString: 'assert(JSON.stringify(splitify("Hello World,I-am code")) === JSON.stringify(["Hello", "World", "I", "am", "code"]), "<code>splitify("Hello World,I-am code")</code> should return <code>["Hello", "World", "I", "am", "code"]</code>.");'
- text: '<code>splitify("Earth-is-our home")</code> should return <code>["Earth", "is", "our", "home"]</code>.'
testString: 'assert(JSON.stringify(splitify("Earth-is-our home")) === JSON.stringify(["Earth", "is", "our", "home"]), "<code>splitify("Earth-is-our home")</code> should return <code>["Earth", "is", "our", "home"]</code>.");'
- text: '<code>splitify("This.is.a-sentence")</code> should return <code>["This", "is", "a", "sentence"]</code>.'
testString: 'assert(JSON.stringify(splitify("This.is.a-sentence")) === JSON.stringify(["This", "is", "a", "sentence"]), "<code>splitify("This.is.a-sentence")</code> should return <code>["This", "is", "a", "sentence"]</code>.");'
testString: assert(code.match(/\.split/g), 'Your code should use the <code>split</code> method.');
- text: <code>splitify("Hello World,I-am code")</code> should return <code>["Hello", "World", "I", "am", "code"]</code>.
testString: assert(JSON.stringify(splitify("Hello World,I-am code")) === JSON.stringify(["Hello", "World", "I", "am", "code"]), '<code>splitify("Hello World,I-am code")</code> should return <code>["Hello", "World", "I", "am", "code"]</code>.');
- text: <code>splitify("Earth-is-our home")</code> should return <code>["Earth", "is", "our", "home"]</code>.
testString: assert(JSON.stringify(splitify("Earth-is-our home")) === JSON.stringify(["Earth", "is", "our", "home"]), '<code>splitify("Earth-is-our home")</code> should return <code>["Earth", "is", "our", "home"]</code>.');
- text: <code>splitify("This.is.a-sentence")</code> should return <code>["This", "is", "a", "sentence"]</code>.
testString: assert(JSON.stringify(splitify("This.is.a-sentence")) === JSON.stringify(["This", "is", "a", "sentence"]), '<code>splitify("This.is.a-sentence")</code> should return <code>["This", "is", "a", "sentence"]</code>.');
```

View File

@ -27,13 +27,13 @@ Note: The data (the number of cups of tea) is supplied as the last argument. We'
```yml
tests:
- text: The <code>tea4GreenTeamFCC</code> variable should hold 27 cups of green tea for the team.
testString: 'assert(tea4GreenTeamFCC.length === 27, "The <code>tea4GreenTeamFCC</code> variable should hold 27 cups of green tea for the team.");'
testString: assert(tea4GreenTeamFCC.length === 27, 'The <code>tea4GreenTeamFCC</code> variable should hold 27 cups of green tea for the team.');
- text: The <code>tea4GreenTeamFCC</code> variable should hold cups of green tea.
testString: 'assert(tea4GreenTeamFCC[0] === "greenTea", "The <code>tea4GreenTeamFCC</code> variable should hold cups of green tea.");'
testString: assert(tea4GreenTeamFCC[0] === 'greenTea', 'The <code>tea4GreenTeamFCC</code> variable should hold cups of green tea.');
- text: The <code>tea4BlackTeamFCC</code> variable should hold 13 cups of black tea.
testString: 'assert(tea4BlackTeamFCC.length === 13, "The <code>tea4BlackTeamFCC</code> variable should hold 13 cups of black tea.");'
testString: assert(tea4BlackTeamFCC.length === 13, 'The <code>tea4BlackTeamFCC</code> variable should hold 13 cups of black tea.');
- text: The <code>tea4BlackTeamFCC</code> variable should hold cups of black tea.
testString: 'assert(tea4BlackTeamFCC[0] === "blackTea", "The <code>tea4BlackTeamFCC</code> variable should hold cups of black tea.");'
testString: assert(tea4BlackTeamFCC[0] === 'blackTea', 'The <code>tea4BlackTeamFCC</code> variable should hold cups of black tea.');
```

View File

@ -30,7 +30,7 @@ Work through the code and see if you can figure out the problem, then advance to
```yml
tests:
- text: Move ahead to understand the error.
testString: 'assert(true, "Move ahead to understand the error.");'
testString: assert(true, 'Move ahead to understand the error.');
```

View File

@ -22,13 +22,13 @@ Use the <code>every</code> method inside the <code>checkPositive</code> function
```yml
tests:
- text: Your code should use the <code>every</code> method.
testString: 'assert(code.match(/\.every/g), "Your code should use the <code>every</code> method.");'
- text: '<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>false</code>.'
testString: 'assert(!checkPositive([1, 2, 3, -4, 5]), "<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>false</code>.");'
- text: '<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.'
testString: 'assert(checkPositive([1, 2, 3, 4, 5]), "<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.");'
- text: '<code>checkPositive([1, -2, 3, -4, 5])</code> should return <code>false</code>.'
testString: 'assert(!checkPositive([1, -2, 3, -4, 5]), "<code>checkPositive([1, -2, 3, -4, 5])</code> should return <code>false</code>.");'
testString: assert(code.match(/\.every/g), 'Your code should use the <code>every</code> method.');
- text: <code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>false</code>.
testString: assert(!checkPositive([1, 2, 3, -4, 5]), '<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>false</code>.');
- text: <code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.
testString: assert(checkPositive([1, 2, 3, 4, 5]), '<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.');
- text: <code>checkPositive([1, -2, 3, -4, 5])</code> should return <code>false</code>.
testString: assert(!checkPositive([1, -2, 3, -4, 5]), '<code>checkPositive([1, -2, 3, -4, 5])</code> should return <code>false</code>.');
```

View File

@ -21,13 +21,13 @@ The variable <code>watchList</code> holds an array of objects with information o
```yml
tests:
- text: The <code>watchList</code> variable should not change.
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", 'The <code>watchList</code> variable should not change.');
- text: Your code should use the <code>filter</code> method.
testString: 'assert(code.match(/\.filter/g), "Your code should use the <code>filter</code> method.");'
testString: assert(code.match(/\.filter/g), 'Your code should use the <code>filter</code> method.');
- text: Your code should not use a <code>for</code> loop.
testString: 'assert(!code.match(/for\s*?\(.+?\)/g), "Your code should not use a <code>for</code> loop.");'
testString: assert(!code.match(/for\s*?\(.+?\)/g), 'Your code should not use a <code>for</code> loop.');
- text: '<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.'
testString: 'assert.deepEqual(filteredList, [{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}], "<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.");'
testString: 'assert.deepEqual(filteredList, [{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}], ''<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.'');'
```

View File

@ -24,13 +24,13 @@ The <code>watchList</code> array holds objects with information on several movie
```yml
tests:
- text: The <code>watchList</code> variable should not change.
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", 'The <code>watchList</code> variable should not change.');
- text: Your code should not use a <code>for</code> loop.
testString: 'assert(!code.match(/for\s*?\(.+?\)/g), "Your code should not use a <code>for</code> loop.");'
testString: assert(!code.match(/for\s*?\(.+?\)/g), 'Your code should not use a <code>for</code> loop.');
- text: Your code should use the <code>map</code> method.
testString: 'assert(code.match(/\.map/g), "Your code should use the <code>map</code> method.");'
- text: '<code>rating</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.'
testString: 'assert(JSON.stringify(rating) === JSON.stringify([{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]), "<code>rating</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.");'
testString: assert(code.match(/\.map/g), 'Your code should use the <code>map</code> method.');
- text: <code>rating</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.
testString: assert(JSON.stringify(rating) === JSON.stringify([{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]), '<code>rating</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.');
```
@ -178,11 +178,125 @@ console.log(JSON.stringify(rating));
<section id='solution'>
```js
// the global variable
var watchList = [
{
"Title": "Inception",
"Year": "2010",
"Rated": "PG-13",
"Released": "16 Jul 2010",
"Runtime": "148 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Christopher Nolan",
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
"Language": "English, Japanese, French",
"Country": "USA, UK",
"Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.8",
"imdbVotes": "1,446,708",
"imdbID": "tt1375666",
"Type": "movie",
"Response": "True"
},
{
"Title": "Interstellar",
"Year": "2014",
"Rated": "PG-13",
"Released": "07 Nov 2014",
"Runtime": "169 min",
"Genre": "Adventure, Drama, Sci-Fi",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan, Christopher Nolan",
"Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
"Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
"Language": "English",
"Country": "USA, UK",
"Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.6",
"imdbVotes": "910,366",
"imdbID": "tt0816692",
"Type": "movie",
"Response": "True"
},
{
"Title": "The Dark Knight",
"Year": "2008",
"Rated": "PG-13",
"Released": "18 Jul 2008",
"Runtime": "152 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
"Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
"Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
"Language": "English, Mandarin",
"Country": "USA, UK",
"Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
"Metascore": "82",
"imdbRating": "9.0",
"imdbVotes": "1,652,832",
"imdbID": "tt0468569",
"Type": "movie",
"Response": "True"
},
{
"Title": "Batman Begins",
"Year": "2005",
"Rated": "PG-13",
"Released": "15 Jun 2005",
"Runtime": "140 min",
"Genre": "Action, Adventure",
"Director": "Christopher Nolan",
"Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
"Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
"Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
"Language": "English, Urdu, Mandarin",
"Country": "USA, UK",
"Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
"Metascore": "70",
"imdbRating": "8.3",
"imdbVotes": "972,584",
"imdbID": "tt0372784",
"Type": "movie",
"Response": "True"
},
{
"Title": "Avatar",
"Year": "2009",
"Rated": "PG-13",
"Released": "18 Dec 2009",
"Runtime": "162 min",
"Genre": "Action, Adventure, Fantasy",
"Director": "James Cameron",
"Writer": "James Cameron",
"Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
"Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language": "English, Spanish",
"Country": "USA, UK",
"Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
"Metascore": "83",
"imdbRating": "7.9",
"imdbVotes": "876,575",
"imdbID": "tt0499549",
"Type": "movie",
"Response": "True"
}
];
var rating = watchList.map(function(movie) {
return {
title: movie["Title"],
rating: movie["imdbRating"]
}
})
});
```
</section>

View File

@ -23,13 +23,13 @@ The variable <code>watchList</code> holds an array of objects with information o
```yml
tests:
- text: The <code>watchList</code> variable should not change.
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
testString: assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", 'The <code>watchList</code> variable should not change.');
- text: Your code should use the <code>reduce</code> method.
testString: 'assert(code.match(/\.reduce/g), "Your code should use the <code>reduce</code> method.");'
testString: assert(code.match(/\.reduce/g), 'Your code should use the <code>reduce</code> method.');
- text: The <code>averageRating</code> should equal 8.675.
testString: 'assert(averageRating == 8.675, "The <code>averageRating</code> should equal 8.675.");'
testString: assert(averageRating == 8.675, 'The <code>averageRating</code> should equal 8.675.');
- text: Your code should not use a <code>for</code> loop.
testString: 'assert(!code.match(/for\s*?\(.*\)/g), "Your code should not use a <code>for</code> loop.");'
testString: assert(!code.match(/for\s*?\(.*\)/g), 'Your code should not use a <code>for</code> loop.');
```

View File

@ -22,13 +22,13 @@ Use the <code>some</code> method inside the <code>checkPositive</code> function
```yml
tests:
- text: Your code should use the <code>some</code> method.
testString: 'assert(code.match(/\.some/g), "Your code should use the <code>some</code> method.");'
- text: '<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>true</code>.'
testString: 'assert(checkPositive([1, 2, 3, -4, 5]), "<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>true</code>.");'
- text: '<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.'
testString: 'assert(checkPositive([1, 2, 3, 4, 5]), "<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.");'
- text: '<code>checkPositive([-1, -2, -3, -4, -5])</code> should return <code>false</code>.'
testString: 'assert(!checkPositive([-1, -2, -3, -4, -5]), "<code>checkPositive([-1, -2, -3, -4, -5])</code> should return <code>false</code>.");'
testString: assert(code.match(/\.some/g), 'Your code should use the <code>some</code> method.');
- text: <code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>true</code>.
testString: assert(checkPositive([1, 2, 3, -4, 5]), '<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>true</code>.');
- text: <code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.
testString: assert(checkPositive([1, 2, 3, 4, 5]), '<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.');
- text: <code>checkPositive([-1, -2, -3, -4, -5])</code> should return <code>false</code>.
testString: assert(!checkPositive([-1, -2, -3, -4, -5]), '<code>checkPositive([-1, -2, -3, -4, -5])</code> should return <code>false</code>.');
```