diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/breadth-first-search.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/breadth-first-search.english.md index f762e5f1fe..ccf590cb40 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/breadth-first-search.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/breadth-first-search.english.md @@ -29,13 +29,13 @@ Your function will output a JavaScript object key-value pairs with the node and ```yml tests: - text: 'The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]] with a start node of 1 should return {0: 1, 1: 0, 2: 1, 3: 2}' - testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]; var results = bfs(graph, 1); return isEquivalent(results, {0: 1, 1: 0, 2: 1, 3: 2})})(), ''The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]] with a start node of 1 should return {0: 1, 1: 0, 2: 1, 3: 2}'');' + testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]; var results = bfs(graph, 1); return isEquivalent(results, {0: 1, 1: 0, 2: 1, 3: 2})})());' - text: 'The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]] with a start node of 1 should return {0: 1, 1: 0, 2: 1, 3: Infinity}' - testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]; var results = bfs(graph, 1); return isEquivalent(results, {0: 1, 1: 0, 2: 1, 3: Infinity})})(), ''The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]] with a start node of 1 should return {0: 1, 1: 0, 2: 1, 3: Infinity}'');' + testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]; var results = bfs(graph, 1); return isEquivalent(results, {0: 1, 1: 0, 2: 1, 3: Infinity})})());' - text: 'The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]] with a start node of 0 should return {0: 0, 1: 1, 2: 2, 3: 3}' - testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]; var results = bfs(graph, 0); return isEquivalent(results, {0: 0, 1: 1, 2: 2, 3: 3})})(), ''The input graph [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]] with a start node of 0 should return {0: 0, 1: 1, 2: 2, 3: 3}'');' + testString: 'assert((function() { var graph = [[0, 1, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1], [0, 0, 1, 0]]; var results = bfs(graph, 0); return isEquivalent(results, {0: 0, 1: 1, 2: 2, 3: 3})})());' - text: 'The input graph [[0, 1], [1, 0]] with a start node of 0 should return {0: 0, 1: 1}' - testString: 'assert((function() { var graph = [[0, 1], [1, 0]]; var results = bfs(graph, 0); return isEquivalent(results, {0: 0, 1: 1})})(), ''The input graph [[0, 1], [1, 0]] with a start node of 0 should return {0: 0, 1: 1}'');' + testString: 'assert((function() { var graph = [[0, 1], [1, 0]]; var results = bfs(graph, 0); return isEquivalent(results, {0: 0, 1: 1})})());' ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md index 41fbabfba0..e0a1803ebc 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/create-a-map-data-structure.english.md @@ -34,7 +34,7 @@ tests: - text: The Map data structure exists. testString: assert((function() { var test = false; if (typeof Map !== 'undefined') { test = new Map() }; return (typeof test == 'object')})(), 'The Map data structure exists.'); - text: 'The Map object has the following methods: add, remove, get, has, values, clear, and size.' - testString: "assert((function() { var test = false; if (typeof Map !== 'undefined') { test = new Map() }; return (typeof test.add == 'function' && typeof test.remove == 'function' && typeof test.get == 'function' && typeof test.has == 'function' && typeof test.values == 'function' && typeof test.clear == 'function' && typeof test.size == 'function')})(), 'The Map object has the following methods: add, remove, get, has, values, clear, and size.');" + testString: "assert((function() { var test = false; if (typeof Map !== 'undefined') { test = new Map() }; return (typeof test.add == 'function' && typeof test.remove == 'function' && typeof test.get == 'function' && typeof test.has == 'function' && typeof test.values == 'function' && typeof test.clear == 'function' && typeof test.size == 'function')})());" - text: The add method adds items to the map. testString: assert((function() { var test = false; if (typeof Map !== 'undefined') { test = new Map() }; test.add(5,6); test.add(2,3); test.add(2,5); return (test.size() == 2)})(), 'The add method adds items to the map.'); - text: The has method returns true for added items and false for absent items. diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/delete-a-node-with-two-children-in-a-binary-search-tree.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/delete-a-node-with-two-children-in-a-binary-search-tree.english.md index f758d3b1e3..540a2e9c70 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/delete-a-node-with-two-children-in-a-binary-search-tree.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/delete-a-node-with-two-children-in-a-binary-search-tree.english.md @@ -27,11 +27,11 @@ tests: - text: The binary search tree has a method called remove. testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; return (typeof test.remove == 'function')})(), 'The binary search tree has a method called remove.'); - text: Trying to remove an element that does not exist returns null. - testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; return (typeof test.remove == 'function') ? (test.remove(100) == null) : false})(), 'Trying to remove an element that does not exist returns null.');" + testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; return (typeof test.remove == 'function') ? (test.remove(100) == null) : false})());" - text: If the root node has no children, deleting it sets the root to null. - testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; test.add(500); test.remove(500); return (typeof test.remove == 'function') ? (test.inorder() == null) : false})(), 'If the root node has no children, deleting it sets the root to null.');" + testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; test.add(500); test.remove(500); return (typeof test.remove == 'function') ? (test.inorder() == null) : false})());" - text: The remove method removes leaf nodes from the tree - testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; test.add(5); test.add(3); test.add(7); test.add(6); test.add(10); test.add(12); test.remove(3); test.remove(12); test.remove(10); return (typeof test.remove == 'function') ? (test.inorder().join('') == '567') : false})(), 'The remove method removes leaf nodes from the tree');" + testString: "assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; test.add(5); test.add(3); test.add(7); test.add(6); test.add(10); test.add(12); test.remove(3); test.remove(12); test.remove(10); return (typeof test.remove == 'function') ? (test.inorder().join('') == '567') : false})());" - text: The remove method removes nodes with one child. testString: assert((function() { var test = false; if (typeof BinarySearchTree !== 'undefined') { test = new BinarySearchTree() } else { return false; }; if (typeof test.remove !== 'function') { return false; }; test.add(-1); test.add(3); test.add(7); test.add(16); test.remove(16); test.remove(7); test.remove(3); return (test.inorder().join('') == '-1'); })(), 'The remove method removes nodes with one child.'); - text: Removing the root in a tree with two nodes sets the second to be the root. diff --git a/curriculum/challenges/english/08-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md b/curriculum/challenges/english/08-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md index 2893554b89..5fc3e00c29 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/data-structures/insert-an-element-into-a-max-heap.english.md @@ -40,7 +40,7 @@ tests: - text: MaxHeap has a method called print. testString: assert((function() { var test = false; if (typeof MaxHeap !== 'undefined') { test = new MaxHeap() } else { return false; }; return (typeof test.print == 'function')})(), 'MaxHeap has a method called print.'); - text: The insert method adds elements according to the max heap property. - testString: 'assert((function() { var test = false; if (typeof MaxHeap !== ''undefined'') { test = new MaxHeap() } else { return false; }; test.insert(50); test.insert(100); test.insert(700); test.insert(32); test.insert(51); let result = test.print(); return ((result.length == 5) ? result[0] == 700 : result[1] == 700) })(), ''The insert method adds elements according to the max heap property.'');' + testString: 'assert((function() { var test = false; if (typeof MaxHeap !== ''undefined'') { test = new MaxHeap() } else { return false; }; test.insert(50); test.insert(100); test.insert(700); test.insert(32); test.insert(51); let result = test.print(); return ((result.length == 5) ? result[0] == 700 : result[1] == 700) })());' ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-34-digit-factorials.english.md b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-34-digit-factorials.english.md index f85dc2159d..892a5bf968 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-34-digit-factorials.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/project-euler/problem-34-digit-factorials.english.md @@ -22,7 +22,7 @@ Note: as 1! = 1 and 2! = 2 are not sums they are not included. ```yml tests: - text: 'digitFactorial() should return { sum: 40730, numbers: [145, 40585] }.' - testString: "assert.deepEqual(digitFactorial(), { sum: 40730, numbers: [145, 40585] }, 'digitFactorial() should return { sum: 40730, numbers: [145, 40585] }.');" + testString: "assert.deepEqual(digitFactorial(), { sum: 40730, numbers: [145, 40585] });" ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md index da8ed47bde..fe3e957a15 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/align-columns.english.md @@ -45,11 +45,11 @@ tests: - text: formatText is a function. testString: assert(typeof formatText === 'function', 'formatText is a function.'); - text: 'formatText with the above input and "right" justification should produce the following: ' - testString: 'assert.strictEqual(formatText(testInput, ''right''), rightAligned, ''formatText with the above input and "right" justification should produce the following: '');' + testString: 'assert.strictEqual(formatText(testInput, ''right''), rightAligned);' - text: 'formatText with the above input and "left" justification should produce the following: ' - testString: 'assert.strictEqual(formatText(testInput, ''left''), leftAligned, ''formatText with the above input and "left" justification should produce the following: '');' + testString: 'assert.strictEqual(formatText(testInput, ''left''), leftAligned);' - text: 'formatText with the above input and "center" justification should produce the following: ' - testString: 'assert.strictEqual(formatText(testInput, ''center''), centerAligned, ''formatText with the above input and "center" justification should produce the following: '');' + testString: 'assert.strictEqual(formatText(testInput, ''center''), centerAligned);' ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deal-cards-for-freecell.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deal-cards-for-freecell.english.md index 1a9d1632e8..d46c309c21 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deal-cards-for-freecell.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deal-cards-for-freecell.english.md @@ -84,9 +84,9 @@ tests: - text: dealFreeCell(seed) should return an array of length 7. testString: assert(dealFreeCell(1).length === 7, 'dealFreeCell(seed) should return an array of length 7.'); - text: "dealFreeCell(1) should return an array identical to example \"Game #1\"" - testString: "assert.deepEqual(dealFreeCell(1), game1, 'dealFreeCell(1) should return an array identical to example \"Game #1\"');" + testString: "assert.deepEqual(dealFreeCell(1), game1);" - text: "dealFreeCell(617) should return an array identical to example \"Game #617\"" - testString: "assert.deepEqual(dealFreeCell(617), game617, 'dealFreeCell(617) should return an array identical to example \"Game #617\"');" + testString: "assert.deepEqual(dealFreeCell(617), game617);" ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deepcopy.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deepcopy.english.md index f33b3f3e3f..49cf3ec221 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deepcopy.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/deepcopy.english.md @@ -29,7 +29,7 @@ tests: - text: deepcopy should be a function. testString: assert(typeof deepcopy === 'function', 'deepcopy should be a function.'); - text: 'deepcopy({test: "test"}) should return an object.' - testString: 'assert(typeof deepcopy(obj1) === ''object'', ''deepcopy({test: "test"}) should return an object.'');' + testString: 'assert(typeof deepcopy(obj1) === ''object'');' - text: Should not return the same object that was provided. testString: assert(deepcopy(obj2) != obj2, 'Should not return the same object that was provided.'); - text: When passed an object containing an array, should return a deep copy of the object. diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/harshad-or-niven-series.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/harshad-or-niven-series.english.md index 40adc0dad9..1e0da5adb8 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/harshad-or-niven-series.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/harshad-or-niven-series.english.md @@ -25,7 +25,7 @@ tests: - text: isHarshadOrNiven is a function. testString: assert(typeof isHarshadOrNiven === 'function', 'isHarshadOrNiven is a function.'); - text: 'isHarshadOrNiven() should return {"firstTwenty": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42],"firstOver1000": 1002}' - testString: 'assert.deepEqual(isHarshadOrNiven(), res, ''isHarshadOrNiven() should return {"firstTwenty": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 18, 20, 21, 24, 27, 30, 36, 40, 42],"firstOver1000": 1002}'');' + testString: assert.deepEqual(isHarshadOrNiven(), res); ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-from-two-arrays.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-from-two-arrays.english.md index fb4c976d0c..db5cb3b5c5 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-from-two-arrays.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-from-two-arrays.english.md @@ -26,17 +26,17 @@ tests: - text: arrToObj is a function. testString: assert(typeof arrToObj === 'function', 'arrToObj is a function.'); - text: 'arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d", "e"]) should return { 1: "a", 2: "b", 3: "c", 4: "d", 5: "e" }' - testString: 'assert.deepEqual(arrToObj(...testCases[0]), res[0], ''arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d", "e"]) should return { 1: "a", 2: "b", 3: "c", 4: "d", 5: "e" }'');' + testString: assert.deepEqual(arrToObj(...testCases[0]), res[0]); - text: 'arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d"]) should return { 1: "a", 2: "b", 3: "c", 4: "d", 5: undefined }' - testString: 'assert.deepEqual(arrToObj(...testCases[1]), res[1], ''arrToObj([1, 2, 3, 4, 5], ["a", "b", "c", "d"]) should return { 1: "a", 2: "b", 3: "c", 4: "d", 5: undefined }'');' + testString: assert.deepEqual(arrToObj(...testCases[1]), res[1]); - text: 'arrToObj([1, 2, 3], ["a", "b", "c", "d", "e"]) should return { 1: "a", 2: "b", 3: "c" }' - testString: 'assert.deepEqual(arrToObj(...testCases[2]), res[2], ''arrToObj([1, 2, 3], ["a", "b", "c", "d", "e"]) should return { 1: "a", 2: "b", 3: "c" }'');' + testString: assert.deepEqual(arrToObj(...testCases[2]), res[2]); - text: 'arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4, 5]) should return { "a": 1, "b": 2, "c": 3 , "d": 4, "e": 5 }' - testString: 'assert.deepEqual(arrToObj(...testCases[3]), res[3], ''arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4, 5]) should return { "a": 1, "b": 2, "c": 3 , "d": 4, "e": 5 }'');' + testString: assert.deepEqual(arrToObj(...testCases[3]), res[3]); - text: 'arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4]) should return { "a": 1, "b": 2, "c": 3 , "d": 4, "e": undefined }' - testString: 'assert.deepEqual(arrToObj(...testCases[4]), res[4], ''arrToObj(["a", "b", "c", "d", "e"], [1, 2, 3, 4]) should return { "a": 1, "b": 2, "c": 3 , "d": 4, "e": undefined }'');' + testString: assert.deepEqual(arrToObj(...testCases[4]), res[4]); - text: 'arrToObj(["a", "b", "c"], [1, 2, 3, 4, 5]) should return { "a": 1, "b": 2, "c": 3 }' - testString: 'assert.deepEqual(arrToObj(...testCases[5]), res[5], ''arrToObj(["a", "b", "c"], [1, 2, 3, 4, 5]) should return { "a": 1, "b": 2, "c": 3 }'');' + testString: assert.deepEqual(arrToObj(...testCases[5]), res[5]); ``` diff --git a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md index bb24ea02be..67a9fb43d0 100644 --- a/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md +++ b/curriculum/challenges/english/08-coding-interview-prep/rosetta-code/hash-join.english.md @@ -175,7 +175,7 @@ tests: - text: hashJoin is a function. testString: assert(typeof hashJoin === 'function', 'hashJoin is a function.'); - text: 'hashJoin([{ age: 27, name: "Jonah" }, { age: 18, name: "Alan" }, { age: 28, name: "Glory" }, { age: 18, name: "Popeye" }, { age: 28, name: "Alan" }], [{ character: "Jonah", nemesis: "Whales" }, { character: "Jonah", nemesis: "Spiders" }, { character: "Alan", nemesis: "Ghosts" }, { character:"Alan", nemesis: "Zombies" }, { character: "Glory", nemesis: "Buffy" }, { character: "Bob", nemesis: "foo" }]) should return [{"A_age": 27,"A_name": "Jonah", "B_character": "Jonah", "B_nemesis": "Whales"}, {"A_age": 27,"A_name": "Jonah", "B_character": "Jonah", "B_nemesis": "Spiders"}, {"A_age": 18,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Ghosts"}, {"A_age": 18,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Zombies"}, {"A_age": 28,"A_name": "Glory", "B_character": "Glory", "B_nemesis": "Buffy"}, {"A_age": 28,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Ghosts"}, {"A_age": 28,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Zombies"}]' - testString: 'assert.deepEqual(hashJoin(hash1, hash2), res, ''hashJoin([{ age: 27, name: "Jonah" }, { age: 18, name: "Alan" }, { age: 28, name: "Glory" }, { age: 18, name: "Popeye" }, { age: 28, name: "Alan" }], [{ character: "Jonah", nemesis: "Whales" }, { character: "Jonah", nemesis: "Spiders" }, { character: "Alan", nemesis: "Ghosts" }, { character:"Alan", nemesis: "Zombies" }, { character: "Glory", nemesis: "Buffy" }, { character: "Bob", nemesis: "foo" }]) should return [{"A_age": 27,"A_name": "Jonah", "B_character": "Jonah", "B_nemesis": "Whales"}, {"A_age": 27,"A_name": "Jonah", "B_character": "Jonah", "B_nemesis": "Spiders"}, {"A_age": 18,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Ghosts"}, {"A_age": 18,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Zombies"}, {"A_age": 28,"A_name": "Glory", "B_character": "Glory", "B_nemesis": "Buffy"}, {"A_age": 28,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Ghosts"}, {"A_age": 28,"A_name": "Alan", "B_character": "Alan", "B_nemesis": "Zombies"}]'');' + testString: assert.deepEqual(hashJoin(hash1, hash2), res); ```