fix(curriculum): changed test text to use should for JavaScript Algorithms and Data Structures (#37761)
* fix: corrected typo Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
9886cf7ca2
commit
2c15bcbb43
@@ -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>
|
||||
- text: <code>myArray[0]</code> should be equal to <code>"a"</code>
|
||||
testString: assert.strictEqual(myArray[0], "a");
|
||||
- text: <code>myArray[1]</code> is no longer set to <code>"b"</code>
|
||||
- text: <code>myArray[1]</code> should not be equal to <code>"b"</code>
|
||||
testString: assert.notStrictEqual(myArray[1], "b");
|
||||
- text: <code>myArray[2]</code> is equal to <code>"c"</code>
|
||||
- text: <code>myArray[2]</code> should be equal to <code>"c"</code>
|
||||
testString: assert.strictEqual(myArray[2], "c");
|
||||
- text: <code>myArray[3]</code> is equal to <code>"d"</code>
|
||||
- text: <code>myArray[3]</code> should be equal to <code>"d"</code>
|
||||
testString: assert.strictEqual(myArray[3], "d");
|
||||
|
||||
```
|
||||
|
@@ -27,15 +27,15 @@ We've defined a function, <code>checkInventory</code>, which receives a scanned
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>checkInventory</code> is a function
|
||||
- text: <code>checkInventory</code> should be a function.
|
||||
testString: assert.strictEqual(typeof checkInventory, '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>'
|
||||
- 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});'
|
||||
- text: <code>checkInventory("apples")</code> should return <code>25</code>
|
||||
- text: <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>
|
||||
- text: <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>
|
||||
- text: <code>checkInventory("strawberries")</code> should return <code>27</code>.
|
||||
testString: assert.strictEqual(checkInventory('strawberries'), 27);
|
||||
|
||||
```
|
||||
|
@@ -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
|
||||
- text: <code>foods</code> should be 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>
|
||||
- text: The <code>foods</code> object should have 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>
|
||||
- text: The <code>foods</code> object should have 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>
|
||||
- text: The <code>foods</code> object should have 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
|
||||
- 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);
|
||||
|
||||
```
|
||||
|
@@ -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>
|
||||
- text: The <code>users</code> object should only contain 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
|
||||
- text: The <code>getArrayOfUsers</code> function should return 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);
|
||||
|
||||
```
|
||||
|
@@ -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
|
||||
- text: The <code>user</code> object should have <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
|
||||
- text: The <code>addFriend</code> function should accept a <code>user</code> object and a <code>friend</code> string as arguments and add 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); })());
|
||||
- text: <code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>
|
||||
- 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']);
|
||||
|
||||
```
|
||||
|
@@ -37,13 +37,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
|
||||
- text: <code>userActivity</code> should have <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>
|
||||
- text: <code>userActivity</code> should have 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);
|
||||
- text: The <code>online</code> property is set using dot or bracket notation
|
||||
- text: The <code>online</code> property should be set using dot or bracket notation.
|
||||
testString: 'assert.strictEqual(code.search(/online: 45/), -1);'
|
||||
|
||||
```
|
||||
|
@@ -55,15 +55,15 @@ We have defined a variable called <code>yourArray</code>. Complete the statement
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: yourArray is an array
|
||||
- text: <code>yourArray</code> should be an array.
|
||||
testString: assert.strictEqual(Array.isArray(yourArray), true);
|
||||
- text: <code>yourArray</code> is at least 5 elements long
|
||||
- text: <code>yourArray</code> should be at least 5 elements long.
|
||||
testString: assert.isAtLeast(yourArray.length, 5);
|
||||
- text: <code>yourArray</code> contains at least one <code>boolean</code>
|
||||
- text: <code>yourArray</code> should contain 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>
|
||||
- text: <code>yourArray</code> should contain 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>
|
||||
- text: <code>yourArray</code> should contain at least one <code>string</code>.
|
||||
testString: assert(yourArray.filter( el => typeof el === 'string').length >= 1);
|
||||
|
||||
```
|
||||
|
@@ -27,9 +27,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>'
|
||||
- text: 'The <code>foods</code> object should only have 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);'
|
||||
- text: The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys are removed using <code>delete</code>
|
||||
- text: The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys should be 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