fix(curriculum): Remove unnecessary assert message argument from English challenges JavaScript Algorithms and Data Structures - 03 (#36403)
* fix: rm assert msg basic-data-structures * fix: rm assert msg intermed-algo-scripting * fix: rm assert msg data-structures projects
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
5bf8527523
commit
d78168f7db
@ -43,13 +43,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");
|
||||
- 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");
|
||||
- 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");
|
||||
- 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");
|
||||
|
||||
```
|
||||
|
||||
|
@ -31,11 +31,11 @@ tests:
|
||||
- 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>'');'
|
||||
- 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);
|
||||
- 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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -37,11 +37,11 @@ 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>');
|
||||
- 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));
|
||||
- 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));
|
||||
- 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));
|
||||
|
||||
```
|
||||
|
||||
|
@ -45,15 +45,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');
|
||||
- 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);
|
||||
- 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);
|
||||
- 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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -34,11 +34,11 @@ tests:
|
||||
- text: <code>quickCheck(["onions", "squash", "shallots"], "onions")</code> should return <code>true</code>
|
||||
testString: assert.strictEqual(quickCheck(['onions', 'squash', 'shallots'], 'onions'), true, '<code>quickCheck(["onions", "squash", "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);
|
||||
- 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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -31,7 +31,7 @@ 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>');
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -32,7 +32,7 @@ tests:
|
||||
- text: <code>forecast</code> should return <code>["warm", "sunny"]</code>
|
||||
testString: assert.deepEqual(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']), ['warm', 'sunny'], '<code>forecast</code> should return <code>["warm", "sunny"]</code>');
|
||||
- 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));
|
||||
|
||||
```
|
||||
|
||||
|
@ -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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -38,15 +38,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]]);
|
||||
- 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]]);
|
||||
- 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>');
|
||||
- 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), []);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -20,7 +20,7 @@ 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);
|
||||
- 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');
|
||||
- text: <code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>
|
||||
|
@ -37,11 +37,11 @@ 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);
|
||||
- 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);
|
||||
- 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);
|
||||
- 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'');'
|
||||
|
||||
|
@ -42,9 +42,9 @@ 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>');
|
||||
- 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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -39,9 +39,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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -55,15 +55,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);
|
||||
- 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);
|
||||
- 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);
|
||||
- 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);
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
@ -29,7 +29,7 @@ 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>'');'
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user