diff --git a/challenges/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json b/challenges/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json
index 10b5a1a558..827c2419b3 100644
--- a/challenges/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json
+++ b/challenges/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json
@@ -110,14 +110,14 @@
"releasedOn": "January 1, 2016",
"challengeSeed": [
"function convertToF(celsius) {",
- " var fahrenheit;",
+ " let fahrenheit;",
" return fahrenheit;",
"}",
"",
"convertToF(30);"
],
"solutions": [
- "function convertToF(celsius) {\n var fahrenheit = celsius * 9/5 + 32;\n if ( typeof fahrenheit !== 'undefined' ) {\n return fahrenheit;\n } else {\n return 'fahrenheit not defined';\n }\n}"
+ "function convertToF(celsius) {\n let fahrenheit = celsius * 9/5 + 32;\n\n return fahrenheit;\n}\n\nconvertToF(30);\n"
],
"tests": [
"assert(typeof convertToF(0) === 'number', 'message: convertToF(0)
should return a number');",
@@ -173,7 +173,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function reverseString(str) {\n return str.split('').reverse().join(\"\");\n}\n\nreverseString('hello');\n"
+ "function reverseString(str) {\n return str.split('').reverse().join('');\n}\n\nreverseString(\"hello\");\n"
],
"MDNlinks": [
"Global String Object",
@@ -231,7 +231,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function factorialize(num) {\n return num < 1 ? 1 : num * factorialize(num-1);\n}\n\nfactorialize(5);\n"
+ "function factorialize(num) {\n return num < 1 ? 1 : num * factorialize(num - 1);\n}\n\nfactorialize(5);\n"
],
"MDNlinks": [
"Arithmetic Operators"
@@ -286,7 +286,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function findLongestWordLength(str) {\n return str.split(' ').sort(function(a, b) { return b.length - a.length;})[0].length;\n}\n\nfindLongestWordLength('The quick brown fox jumped over the lazy dog');\n"
+ "function findLongestWordLength(str) {\n return str.split(' ').sort((a, b) => b.length - a.length)[0].length;\n}\n\nfindLongestWordLength(\"The quick brown fox jumped over the lazy dog\");\n"
],
"MDNlinks": [
"String.prototype.split()",
@@ -332,12 +332,12 @@
"assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'message: largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])
should return an array.');",
"assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], 'message: largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])
should return [27, 5, 39, 1001]
.');",
"assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], 'message: largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])
should return [9, 35, 97, 1000000]
.');",
- "assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], 'message: largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])
should return [25, 48, 21, -3]
.');"
+ "assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], 'message: largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])
should return [25, 48, 21, -3]
.');"
],
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function largestOfFour(arr) {\n return arr.map(function(subArr) {\n return Math.max.apply(null, subArr);\n });\n}\n\nlargestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);\n"
+ "function largestOfFour(arr) {\n return arr.map(subArr => Math.max.apply(null, subArr));\n}\n\nlargestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);\n"
],
"MDNlinks": [
"Comparison Operators"
@@ -396,7 +396,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function confirmEnding(str, target) {\n return str.substring(str.length-target.length) === target;\n};\n"
+ "function confirmEnding(str, target) {\n return str.substring(str.length - target.length) === target;\n}\n\nconfirmEnding(\"Bastian\", \"n\");\n"
],
"MDNlinks": [
"String.prototype.substr()",
@@ -448,7 +448,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function repeatStringNumTimes(str, num) {\n if (num < 0) return '';\n return num === 1 ? str : str + repeatStringNumTimes(str, num-1);\n}\n\nrepeatStringNumTimes('abc', 3);\n"
+ "function repeatStringNumTimes(str, num) {\n if (num < 0) return '';\n return num === 1 ? str : str + repeatStringNumTimes(str, num-1);\n}\n\nrepeatStringNumTimes(\"abc\", 3);\n"
],
"MDNlinks": [
"Global String Object"
@@ -497,7 +497,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function truncateString(str, num) {\n if (num >= str.length) {\n return str;\n }\n return str.slice(0, num) + '...';\n}"
+ "function truncateString(str, num) {\n if (num >= str.length) {\n return str;\n }\n\n return str.slice(0, num) + '...';\n}\n\ntruncateString(\"A-tisket a-tasket A green and yellow basket\", 8);\n"
],
"MDNlinks": [
"String.prototype.slice()"
@@ -529,14 +529,14 @@
],
"challengeSeed": [
"function findElement(arr, func) {",
- " var num = 0;",
+ " let num = 0;",
" return num;",
"}",
"",
- "findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });"
+ "findElement([1, 2, 3, 4], num => num % 2 === 0);"
],
"solutions": [
- "function findElement(arr, func) {\n var num;\n arr.some(function(e) {\n if (func(e)) {\n num = e;\n return true;\n }\n });\n return num;\n}"
+ "function findElement(arr, func) {\n let num;\n\n arr.some(e => {\n if (func(e)) {\n num = e;\n return true;\n }\n });\n\n return num;\n}\n\nfindElement([1, 2, 3, 4], num => num % 2 === 0);\n"
],
"tests": [
"assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'message: findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })
should return 8.');",
@@ -589,7 +589,7 @@
"booWho(null);"
],
"solutions": [
- "function booWho(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\n return typeof bool === \"boolean\";\n}\n\nbooWho(null);"
+ "function booWho(bool) {\n return typeof bool === \"boolean\";\n}\n\nbooWho(null);"
],
"tests": [
"assert.strictEqual(booWho(true), true, 'message: booWho(true)
should return true.');",
@@ -660,7 +660,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function titleCase(str) {\n return str.split(' ').map(function(word) {\n return word.charAt(0).toUpperCase() + word.substring(1).toLowerCase();\n }).join(' ');\n}\n\ntitleCase(\"I'm a little tea pot\");\n"
+ "function titleCase(str) {\n return str.split(' ').map(word => word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()).join(' ');\n}\n\ntitleCase(\"I'm a little tea pot\");\n"
],
"MDNlinks": [
"String.prototype.split()"
@@ -704,22 +704,22 @@
"frankenSplice([1, 2, 3], [4, 5, 6], 1);"
],
"tail": [
- "var testArr1 = [1, 2];",
- "var testArr2 = ['a', 'b'];"
+ "let testArr1 = [1, 2];",
+ "let testArr2 = [\"a\", \"b\"];"
],
"tests": [
"assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], 'message: frankenSplice([1, 2, 3], [4, 5], 1)
should return [4, 1, 2, 3, 5]
.');",
- "assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ['a', 1, 2, 'b'], 'message: frankenSplice([1, 2], [\"a\", \"b\"], 1)
should return [\"a\", 1, 2, \"b\"]
.');",
- "assert.deepEqual(frankenSplice(['claw', 'tentacle'], ['head', 'shoulders', 'knees', 'toes'], 2), ['head', 'shoulders', 'claw', 'tentacle', 'knees', 'toes'], 'message: frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2)
should return [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"]
.');",
+ "assert.deepEqual(frankenSplice(testArr1, testArr2, 1), [\"a\", 1, 2, \"b\"], 'message: frankenSplice([1, 2], [\"a\", \"b\"], 1)
should return [\"a\", 1, 2, \"b\"]
.');",
+ "assert.deepEqual(frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2), [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"], 'message: frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2)
should return [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"]
.');",
"assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], 'message: All elements from the first array should be added to the second array in their original order.');",
"assert(testArr1[0] === 1 && testArr1[1] === 2, 'message: The first array should remain the same after the function runs.');",
- "assert(testArr2[0] === 'a' && testArr2[1] === 'b', 'message: The second array should remain the same after the function runs.');"
+ "assert(testArr2[0] === \"a\" && testArr2[1] === \"b\", 'message: The second array should remain the same after the function runs.');"
],
"type": "bonfire",
"isRequired": true,
"isBeta": true,
"solutions": [
- "function frankenSplice(arr1, arr2, n) {\n // It's alive. It's alive!\n var result = arr2.slice();\n for(var i = 0; i < arr1.length; i++) {\n result.splice(n+i, 0, arr1[i]);\n }\n return result;\n}\n\nfrankenSplice([1, 2, 3], [4, 5], 1);\n"
+ "function frankenSplice(arr1, arr2, n) {\n // It's alive. It's alive!\n let result = arr2.slice();\n for (let i = 0; i < arr1.length; i++) {\n result.splice(n+i, 0, arr1[i]);\n }\n return result;\n}\n\nfrankenSplice([1, 2, 3], [4, 5], 1);\n"
],
"MDNlinks": [
"Array.prototype.slice()",
@@ -764,7 +764,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function bouncer(arr) {\n // Don't show a false ID to this bouncer.\n return arr.filter(function(e) {return e;});\n}\n\nbouncer([7, 'ate', '', false, 9]);\n"
+ "function bouncer(arr) {\n return arr.filter(e => e);\n}\n\nbouncer([7, \"ate\", \"\", false, 9]);\n"
],
"MDNlinks": [
"Boolean Objects",
@@ -829,7 +829,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function getIndexToIns(arr, num) {\n arr = arr.sort(function(a, b){return a-b;});\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] >= num)\n {\n return i;\n }\n }\n return arr.length;\n}"
+ "function getIndexToIns(arr, num) {\n arr = arr.sort((a, b) => a - b);\n\n for (let i = 0; i < arr.length; i++) {\n if (arr[i] >= num) {\n return i;\n }\n }\n\n return arr.length;\n}\n\ngetIndexToIns([40, 60], 50);\n"
],
"MDNlinks": [
"Array.prototype.sort()"
@@ -887,7 +887,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function mutation(arr) {\n var hash = Object.create(null);\n arr[0].toLowerCase().split('').forEach(function(c) {\n hash[c] = true;\n });\n return !arr[1].toLowerCase().split('').filter(function(c) {\n return !hash[c];\n }).length;\n}\n\nmutation(['hello', 'hey']);\n"
+ "function mutation(arr) {\n let hash = Object.create(null);\n\n arr[0].toLowerCase().split('').forEach(c => hash[c] = true);\n\n return !arr[1].toLowerCase().split('').filter(c => !hash[c]).length;\n}\n\nmutation([\"hello\", \"hey\"]);\n"
],
"MDNlinks": [
"String.prototype.indexOf()"
@@ -943,7 +943,7 @@
"type": "bonfire",
"isRequired": true,
"solutions": [
- "function chunkArrayInGroups(arr, size) {\n var out = [];\n for (var i = 0; i < arr.length; i+=size) {\n out.push(arr.slice(i,i+size));\n }\n return out;\n}\n\nchunkArrayInGroups(['a', 'b', 'c', 'd'], 2);\n"
+ "function chunkArrayInGroups(arr, size) {\n let out = [];\n\n for (let i = 0; i < arr.length; i += size) {\n out.push(arr.slice(i, i + size));\n }\n\n return out;\n}\n\nchunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2);\n"
],
"MDNlinks": [
"Array.prototype.push()",