diff --git a/challenges/01-front-end-development-certification/intermediate-bonfires.json b/challenges/01-front-end-development-certification/intermediate-bonfires.json
index 8c19bdf850..76bccd494b 100644
--- a/challenges/01-front-end-development-certification/intermediate-bonfires.json
+++ b/challenges/01-front-end-development-certification/intermediate-bonfires.json
@@ -58,26 +58,26 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function diff(arr1, arr2) {",
+ "function diffArray(arr1, arr2) {",
" var newArr = [];",
" // Same, same; but different.",
" return newArr;",
"}",
"",
- "diff([1, 2, 3, 5], [1, 2, 3, 4, 5]);"
+ "diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]);"
],
"solutions": [
- "function diff(arr1, arr2) {\n var newArr = [];\n var h1 = Object.create(null);\n arr1.forEach(function(e) {\n h1[e] = e;\n });\n \n var h2 = Object.create(null);\n arr2.forEach(function(e) {\n h2[e] = e;\n });\n \n Object.keys(h1).forEach(function(e) {\n if (!(e in h2)) newArr.push(h1[e]);\n });\n Object.keys(h2).forEach(function(e) {\n if (!(e in h1)) newArr.push(h2[e]);\n });\n // Same, same; but different.\n return newArr;\n}"
+ "function diffArray(arr1, arr2) {\n var newArr = [];\n var h1 = Object.create(null);\n arr1.forEach(function(e) {\n h1[e] = e;\n });\n \n var h2 = Object.create(null);\n arr2.forEach(function(e) {\n h2[e] = e;\n });\n \n Object.keys(h1).forEach(function(e) {\n if (!(e in h2)) newArr.push(h1[e]);\n });\n Object.keys(h2).forEach(function(e) {\n if (!(e in h1)) newArr.push(h2[e]);\n });\n // Same, same; but different.\n return newArr;\n}"
],
"tests": [
- "assert(typeof diff([1, 2, 3, 5], [1, 2, 3, 4, 5]) === \"object\", 'message: diff([1, 2, 3, 5], [1, 2, 3, 4, 5])
should return an array.');",
- "assert.sameMembers(diff([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"pink wool\"], 'message: [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return [\"pink wool\"]
.');",
- "assert.sameMembers(diff([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"diorite\", \"pink wool\"], 'message: [\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return [\"diorite\", \"pink wool\"]
.');",
- "assert.sameMembers(diff([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], 'message: [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return []
.');",
- "assert.sameMembers(diff([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], 'message: [1, 2, 3, 5], [1, 2, 3, 4, 5]
should return [4]
.');",
- "assert.sameMembers(diff([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], 'message: [1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
should return [\"piglet\", 4]
.');",
- "assert.sameMembers(diff([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], 'message: [], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
should return [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
.');",
- "assert.sameMembers(diff([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]), [1, \"calf\", 3, \"piglet\", 7, \"filly\"], 'message: [1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
should return [1, \"calf\", 3, \"piglet\", 7, \"filly\"]
.');"
+ "assert(typeof diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) === \"object\", 'message: diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
should return an array.');",
+ "assert.sameMembers(diffArray([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"pink wool\"], 'message: [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return [\"pink wool\"]
.');",
+ "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"diorite\", \"pink wool\"], 'message: [\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return [\"diorite\", \"pink wool\"]
.');",
+ "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], 'message: [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return []
.');",
+ "assert.sameMembers(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], 'message: [1, 2, 3, 5], [1, 2, 3, 4, 5]
should return [4]
.');",
+ "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], 'message: [1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
should return [\"piglet\", 4]
.');",
+ "assert.sameMembers(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], 'message: [], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
should return [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
.');",
+ "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]), [1, \"calf\", 3, \"piglet\", 7, \"filly\"], 'message: [1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
should return [1, \"calf\", 3, \"piglet\", 7, \"filly\"]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -109,41 +109,41 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function convert(num) {",
+ "function convertToRoman(num) {",
" return num;",
"}",
"",
- "convert(36);"
+ "convertToRoman(36);"
],
"solutions": [
- "function convert(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
+ "function convertToRoman(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
],
"tests": [
- "assert.deepEqual(convert(2), \"II\", 'message: convert(2)
should return \"II\".');",
- "assert.deepEqual(convert(3), \"III\", 'message: convert(3)
should return \"III\".');",
- "assert.deepEqual(convert(4), \"IV\", 'message: convert(4)
should return \"IV\".');",
- "assert.deepEqual(convert(5), \"V\", 'message: convert(5)
should return \"V\".');",
- "assert.deepEqual(convert(9), \"IX\", 'message: convert(9)
should return \"IX\".');",
- "assert.deepEqual(convert(12), \"XII\", 'message: convert(12)
should return \"XII\".');",
- "assert.deepEqual(convert(16), \"XVI\", 'message: convert(16)
should return \"XVI\".');",
- "assert.deepEqual(convert(29), \"XXIX\", 'message: convert(29)
should return \"XXIX\".');",
- "assert.deepEqual(convert(44), \"XLIV\", 'message: convert(44)
should return \"XLIV\".');",
- "assert.deepEqual(convert(45), \"XLV\", 'message: convert(45)
should return \"XLV\"');",
- "assert.deepEqual(convert(68), \"LXVIII\", 'message: convert(68)
should return \"LXVIII\"');",
- "assert.deepEqual(convert(83), \"LXXXIII\", 'message: convert(83)
should return \"LXXXIII\"');",
- "assert.deepEqual(convert(97), \"XCVII\", 'message: convert(97)
should return \"XCVII\"');",
- "assert.deepEqual(convert(99), \"XCIX\", 'message: convert(99)
should return \"XCIX\"');",
- "assert.deepEqual(convert(500), \"D\", 'message: convert(500)
should return \"D\"');",
- "assert.deepEqual(convert(501), \"DI\", 'message: convert(501)
should return \"DI\"');",
- "assert.deepEqual(convert(649), \"DCXLIX\", 'message: convert(649)
should return \"DCXLIX\"');",
- "assert.deepEqual(convert(798), \"DCCXCVIII\", 'message: convert(798)
should return \"DCCXCVIII\"');",
- "assert.deepEqual(convert(891), \"DCCCXCI\", 'message: convert(891)
should return \"DCCCXCI\"');",
- "assert.deepEqual(convert(1000), \"M\", 'message: convert(1000)
should return \"M\"');",
- "assert.deepEqual(convert(1004), \"MIV\", 'message: convert(1004)
should return \"MIV\"');",
- "assert.deepEqual(convert(1006), \"MVI\", 'message: convert(1006)
should return \"MVI\"');",
- "assert.deepEqual(convert(1023), \"MXXIII\", 'message: convert(1023)
should return \"MXXIII\"');",
- "assert.deepEqual(convert(2014), \"MMXIV\", 'message: convert(2014)
should return \"MMXIV\"');",
- "assert.deepEqual(convert(3999), \"MMMCMXCIX\", 'message: convert(3999)
should return \"MMMCMXCIX\"');"
+ "assert.deepEqual(convertToRoman(2), \"II\", 'message: convertToRoman(2)
should return \"II\".');",
+ "assert.deepEqual(convertToRoman(3), \"III\", 'message: convertToRoman(3)
should return \"III\".');",
+ "assert.deepEqual(convertToRoman(4), \"IV\", 'message: convertToRoman(4)
should return \"IV\".');",
+ "assert.deepEqual(convertToRoman(5), \"V\", 'message: convertToRoman(5)
should return \"V\".');",
+ "assert.deepEqual(convertToRoman(9), \"IX\", 'message: convertToRoman(9)
should return \"IX\".');",
+ "assert.deepEqual(convertToRoman(12), \"XII\", 'message: convertToRoman(12)
should return \"XII\".');",
+ "assert.deepEqual(convertToRoman(16), \"XVI\", 'message: convertToRoman(16)
should return \"XVI\".');",
+ "assert.deepEqual(convertToRoman(29), \"XXIX\", 'message: convertToRoman(29)
should return \"XXIX\".');",
+ "assert.deepEqual(convertToRoman(44), \"XLIV\", 'message: convertToRoman(44)
should return \"XLIV\".');",
+ "assert.deepEqual(convertToRoman(45), \"XLV\", 'message: convertToRoman(45)
should return \"XLV\"');",
+ "assert.deepEqual(convertToRoman(68), \"LXVIII\", 'message: convertToRoman(68)
should return \"LXVIII\"');",
+ "assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'message: convertToRoman(83)
should return \"LXXXIII\"');",
+ "assert.deepEqual(convertToRoman(97), \"XCVII\", 'message: convertToRoman(97)
should return \"XCVII\"');",
+ "assert.deepEqual(convertToRoman(99), \"XCIX\", 'message: convertToRoman(99)
should return \"XCIX\"');",
+ "assert.deepEqual(convertToRoman(500), \"D\", 'message: convertToRoman(500)
should return \"D\"');",
+ "assert.deepEqual(convertToRoman(501), \"DI\", 'message: convertToRoman(501)
should return \"DI\"');",
+ "assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'message: convertToRoman(649)
should return \"DCXLIX\"');",
+ "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'message: convertToRoman(798)
should return \"DCCXCVIII\"');",
+ "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'message: convertToRoman(891)
should return \"DCCCXCI\"');",
+ "assert.deepEqual(convertToRoman(1000), \"M\", 'message: convertToRoman(1000)
should return \"M\"');",
+ "assert.deepEqual(convertToRoman(1004), \"MIV\", 'message: convertToRoman(1004)
should return \"MIV\"');",
+ "assert.deepEqual(convertToRoman(1006), \"MVI\", 'message: convertToRoman(1006)
should return \"MVI\"');",
+ "assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'message: convertToRoman(1023)
should return \"MXXIII\"');",
+ "assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'message: convertToRoman(2014)
should return \"MMXIV\"');",
+ "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'message: convertToRoman(3999)
should return \"MMMCMXCIX\"');"
],
"type": "bonfire",
"MDNlinks": [
@@ -176,22 +176,22 @@
"Remember to use Read-Search-Ask if you get stuck. Write your own code."
],
"challengeSeed": [
- "function where(collection, source) {",
+ "function whereAreYou(collection, source) {",
" var arr = [];",
" // What's in a name?",
" return arr;",
"}",
"",
- "where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" });"
+ "whereAreYou([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" });"
],
"solutions": [
- "function where(collection, source) {\n var arr = [];\n var keys = Object.keys(source);\n collection.forEach(function(e) {\n if(keys.every(function(key) {return e[key] === source[key];})) {\n arr.push(e); \n }\n });\n return arr;\n}"
+ "function whereAreYou(collection, source) {\n var arr = [];\n var keys = Object.keys(source);\n collection.forEach(function(e) {\n if(keys.every(function(key) {return e[key] === source[key];})) {\n arr.push(e); \n }\n });\n return arr;\n}"
],
"tests": [
- "assert.deepEqual(where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }), [{ first: \"Tybalt\", last: \"Capulet\" }], 'message: where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
should return [{ first: \"Tybalt\", last: \"Capulet\" }]
.');",
- "assert.deepEqual(where([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 }), [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], 'message: where([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 })
should return [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }]
.');",
- "assert.deepEqual(where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 }), [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], 'message: where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 })
should return [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }]
.');",
- "assert.deepEqual(where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"c\": 2 }), [{ \"a\": 1, \"b\": 2, \"c\": 2 }], 'message: where([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"c\": 2 })
should return [{ \"a\": 1, \"b\": 2, \"c\": 2 }]
.');"
+ "assert.deepEqual(whereAreYou([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }), [{ first: \"Tybalt\", last: \"Capulet\" }], 'message: whereAreYou([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
should return [{ first: \"Tybalt\", last: \"Capulet\" }]
.');",
+ "assert.deepEqual(whereAreYou([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 }), [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], 'message: whereAreYou([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 })
should return [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }]
.');",
+ "assert.deepEqual(whereAreYou([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 }), [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], 'message: whereAreYou([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"b\": 2 })
should return [{ \"a\": 1, \"b\": 2 }, { \"a\": 1, \"b\": 2, \"c\": 2 }]
.');",
+ "assert.deepEqual(whereAreYou([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"c\": 2 }), [{ \"a\": 1, \"b\": 2, \"c\": 2 }], 'message: whereAreYou([{ \"a\": 1, \"b\": 2 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2, \"c\": 2 }], { \"a\": 1, \"c\": 2 })
should return [{ \"a\": 1, \"b\": 2, \"c\": 2 }]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -279,21 +279,21 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function translate(str) {",
+ "function translatePigLatin(str) {",
" return str;",
"}",
"",
- "translate(\"consonant\");"
+ "translatePigLatin(\"consonant\");"
],
"solutions": [
- "function translate(str) {\n if (isVowel(str.charAt(0))) return str + \"way\";\n var front = [];\n str = str.split('');\n while (str.length && !isVowel(str[0])) {\n front.push(str.shift());\n }\n return [].concat(str, front).join('') + 'ay';\n}\n\nfunction isVowel(c) {\n return ['a', 'e', 'i', 'o', 'u'].indexOf(c.toLowerCase()) !== -1;\n}"
+ "function translatePigLatin(str) {\n if (isVowel(str.charAt(0))) return str + \"way\";\n var front = [];\n str = str.split('');\n while (str.length && !isVowel(str[0])) {\n front.push(str.shift());\n }\n return [].concat(str, front).join('') + 'ay';\n}\n\nfunction isVowel(c) {\n return ['a', 'e', 'i', 'o', 'u'].indexOf(c.toLowerCase()) !== -1;\n}"
],
"tests": [
- "assert.deepEqual(translate(\"california\"), \"aliforniacay\", 'message: translate(\"california\")
should return \"aliforniacay\".');",
- "assert.deepEqual(translate(\"paragraphs\"), \"aragraphspay\", 'message: translate(\"paragraphs\")
should return \"aragraphspay\".');",
- "assert.deepEqual(translate(\"glove\"), \"oveglay\", 'message: translate(\"glove\")
should return \"oveglay\".');",
- "assert.deepEqual(translate(\"algorithm\"), \"algorithmway\", 'message: translate(\"algorithm\")
should return \"algorithmway\".');",
- "assert.deepEqual(translate(\"eight\"), \"eightway\", 'message: translate(\"eight\")
should return \"eightway\".');"
+ "assert.deepEqual(translatePigLatin(\"california\"), \"aliforniacay\", 'message: translatePigLatin(\"california\")
should return \"aliforniacay\".');",
+ "assert.deepEqual(translatePigLatin(\"paragraphs\"), \"aragraphspay\", 'message: translatePigLatin(\"paragraphs\")
should return \"aragraphspay\".');",
+ "assert.deepEqual(translatePigLatin(\"glove\"), \"oveglay\", 'message: translatePigLatin(\"glove\")
should return \"oveglay\".');",
+ "assert.deepEqual(translatePigLatin(\"algorithm\"), \"algorithmway\", 'message: translatePigLatin(\"algorithm\")
should return \"algorithmway\".');",
+ "assert.deepEqual(translatePigLatin(\"eight\"), \"eightway\", 'message: translatePigLatin(\"eight\")
should return \"eightway\".');"
],
"type": "bonfire",
"MDNlinks": [
@@ -332,19 +332,19 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function pair(str) {",
+ "function pairElement(str) {",
" return str;",
"}",
"",
- "pair(\"GCG\");"
+ "pairElement(\"GCG\");"
],
"solutions": [
- "var lookup = Object.create(null);\nlookup.A = 'T';\nlookup.T = 'A';\nlookup.C = 'G';\nlookup.G = 'C';\n\nfunction pair(str) {\n return str.split('').map(function(p) {return [p, lookup[p]];});\n}"
+ "var lookup = Object.create(null);\nlookup.A = 'T';\nlookup.T = 'A';\nlookup.C = 'G';\nlookup.G = 'C';\n\nfunction pairElement(str) {\n return str.split('').map(function(p) {return [p, lookup[p]];});\n}"
],
"tests": [
- "assert.deepEqual(pair(\"ATCGA\"),[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]], 'message: pair(\"ATCGA\")
should return [[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
.');",
- "assert.deepEqual(pair(\"TTGAG\"),[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]], 'message: pair(\"TTGAG\")
should return [[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
.');",
- "assert.deepEqual(pair(\"CTCTA\"),[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]], 'message: pair(\"CTCTA\")
should return [[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
.');"
+ "assert.deepEqual(pairElement(\"ATCGA\"),[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]], 'message: pairElement(\"ATCGA\")
should return [[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
.');",
+ "assert.deepEqual(pairElement(\"TTGAG\"),[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]], 'message: pairElement(\"TTGAG\")
should return [[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
.');",
+ "assert.deepEqual(pairElement(\"CTCTA\"),[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]], 'message: pairElement(\"CTCTA\")
should return [[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -425,27 +425,27 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function boo(bool) {",
+ "function booWho(bool) {",
" // What is the new fad diet for ghost developers? The Boolean.",
" return bool;",
"}",
"",
- "boo(null);"
+ "booWho(null);"
],
"solutions": [
- "function boo(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\n return typeof bool === \"boolean\";\n}\n\nboo(null);"
+ "function booWho(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\n return typeof bool === \"boolean\";\n}\n\nbooWho(null);"
],
"tests": [
- "assert.strictEqual(boo(true), true, 'message: boo(true)
should return true.');",
- "assert.strictEqual(boo(false), true, 'message: boo(false)
should return true.');",
- "assert.strictEqual(boo([1, 2, 3]), false, 'message: boo([1, 2, 3])
should return false.');",
- "assert.strictEqual(boo([].slice), false, 'message: boo([].slice)
should return false.');",
- "assert.strictEqual(boo({ \"a\": 1 }), false, 'message: boo({ \"a\": 1 })
should return false.');",
- "assert.strictEqual(boo(1), false, 'message: boo(1)
should return false.');",
- "assert.strictEqual(boo(NaN), false, 'message: boo(NaN)
should return false.');",
- "assert.strictEqual(boo(\"a\"), false, 'message: boo(\"a\")
should return false.');",
- "assert.strictEqual(boo(\"true\"), false, 'message: boo(\"true\")
should return false.');",
- "assert.strictEqual(boo(\"false\"), false, 'message: boo(\"false\")
should return false.');"
+ "assert.strictEqual(booWho(true), true, 'message: booWho(true)
should return true.');",
+ "assert.strictEqual(booWho(false), true, 'message: booWho(false)
should return true.');",
+ "assert.strictEqual(booWho([1, 2, 3]), false, 'message: booWho([1, 2, 3])
should return false.');",
+ "assert.strictEqual(booWho([].slice), false, 'message: booWho([].slice)
should return false.');",
+ "assert.strictEqual(booWho({ \"a\": 1 }), false, 'message: booWho({ \"a\": 1 })
should return false.');",
+ "assert.strictEqual(booWho(1), false, 'message: booWho(1)
should return false.');",
+ "assert.strictEqual(booWho(NaN), false, 'message: booWho(NaN)
should return false.');",
+ "assert.strictEqual(booWho(\"a\"), false, 'message: booWho(\"a\")
should return false.');",
+ "assert.strictEqual(booWho(\"true\"), false, 'message: booWho(\"true\")
should return false.');",
+ "assert.strictEqual(booWho(\"false\"), false, 'message: booWho(\"false\")
should return false.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -477,20 +477,20 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function unite(arr1, arr2, arr3) {",
+ "function uniteUnique(arr1, arr2, arr3) {",
" return arr1;",
"}",
"",
- "unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);"
+ "uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);"
],
"solutions": [
- "function unite(arr1, arr2, arr3) {\n return [].slice.call(arguments).reduce(function(a, b) {\n return [].concat(a, b.filter(function(e) {return a.indexOf(e) === -1;}));\n }, []);\n}"
+ "function uniteUnique(arr1, arr2, arr3) {\n return [].slice.call(arguments).reduce(function(a, b) {\n return [].concat(a, b.filter(function(e) {return a.indexOf(e) === -1;}));\n }, []);\n}"
],
"tests": [
- "assert.deepEqual(unite([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'message: unite([1, 3, 2], [5, 2, 1, 4], [2, 1])
should return [1, 3, 2, 5, 4]
.');",
- "assert.deepEqual(unite([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'message: unite([1, 3, 2], [1, [5]], [2, [4]])
should return [1, 3, 2, [5], [4]]
.');",
- "assert.deepEqual(unite([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'message: unite([1, 2, 3], [5, 2, 1])
should return [1, 2, 3, 5]
.');",
- "assert.deepEqual(unite([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [1, 2, 3, 5, 4, 6, 7, 8], 'message: unite([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
should return [1, 2, 3, 5, 4, 6, 7, 8]
.');"
+ "assert.deepEqual(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'message: uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
should return [1, 3, 2, 5, 4]
.');",
+ "assert.deepEqual(uniteUnique([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'message: uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
should return [1, 3, 2, [5], [4]]
.');",
+ "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'message: uniteUnique([1, 2, 3], [5, 2, 1])
should return [1, 2, 3, 5]
.');",
+ "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [1, 2, 3, 5, 4, 6, 7, 8], 'message: uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
should return [1, 2, 3, 5, 4, 6, 7, 8]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -524,24 +524,24 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function convert(str) {",
+ "function convertHTML(str) {",
" // :)",
" return str;",
"}",
"",
- "convert(\"Dolce & Gabbana\");"
+ "convertHTML(\"Dolce & Gabbana\");"
],
"solutions": [
- "var MAP = { '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''};\n\nfunction convert(str) {\n return str.replace(/[&<>\"']/g, function(c) {\n return MAP[c];\n });\n}"
+ "var MAP = { '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''};\n\nfunction convertHTML(str) {\n return str.replace(/[&<>\"']/g, function(c) {\n return MAP[c];\n });\n}"
],
"tests": [
- "assert.match(convert(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'message: convert(\"Dolce & Gabbana\")
should return Dolce & Gabbana
.');",
- "assert.match(convert(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'message: convert(\"Hamburgers < Pizza < Tacos\")
should return Hamburgers < Pizza < Tacos
.');",
- "assert.match(convert(\"Sixty > twelve\"), /Sixty > twelve/, 'message: convert(\"Sixty > twelve\")
should return Sixty > twelve
.');",
- "assert.match(convert('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'message: convert('Stuff in \"quotation marks\"')
should return Stuff in "quotation marks"
.');",
- "assert.match(convert(\"Shindler's List\"), /Shindler's List/, 'message: convert(\"Shindler's List\")
should return Shindler's List
.');",
- "assert.match(convert('<>'), /<>/, 'message: convert(\"<>\")
should return <>
.');",
- "assert.strictEqual(convert('abc'), 'abc', 'message: convert(\"abc\")
should return abc
.');"
+ "assert.match(convertHTML(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'message: convertHTML(\"Dolce & Gabbana\")
should return Dolce & Gabbana
.');",
+ "assert.match(convertHTML(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'message: convertHTML(\"Hamburgers < Pizza < Tacos\")
should return Hamburgers < Pizza < Tacos
.');",
+ "assert.match(convertHTML(\"Sixty > twelve\"), /Sixty > twelve/, 'message: convertHTML(\"Sixty > twelve\")
should return Sixty > twelve
.');",
+ "assert.match(convertHTML('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'message: convertHTML('Stuff in \"quotation marks\"')
should return Stuff in "quotation marks"
.');",
+ "assert.match(convertHTML(\"Shindler's List\"), /Shindler's List/, 'message: convertHTML(\"Shindler's List\")
should return Shindler's List
.');",
+ "assert.match(convertHTML('<>'), /<>/, 'message: convertHTML(\"<>\")
should return <>
.');",
+ "assert.strictEqual(convertHTML('abc'), 'abc', 'message: convertHTML(\"abc\")
should return abc
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -754,19 +754,19 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function find(arr, func) {",
+ "function findElement(arr, func) {",
" var num = 0;",
" return num;",
"}",
"",
- "find([1, 2, 3, 4], function(num){ return num % 2 === 0; });"
+ "findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });"
],
"solutions": [
- "function find(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 var num;\n arr.some(function(e) {\n if (func(e)) {\n num = e;\n return true;\n }\n });\n return num;\n}"
],
"tests": [
- "assert.strictEqual(find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'message: find([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })
should return 8.');",
- "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'message: find([1, 3, 5, 9], function(num) { return num % 2 === 0; })
should return undefined.');"
+ "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.');",
+ "assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'message: findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })
should return undefined.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -795,23 +795,23 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function drop(arr, func) {",
+ "function dropElements(arr, func) {",
" // Drop them elements.",
" return arr;",
"}",
"",
- "drop([1, 2, 3], function(n) {return n < 3; });"
+ "dropElements([1, 2, 3], function(n) {return n < 3; });"
],
"solutions": [
- "function drop(arr, func) {\n // Drop them elements.\n while (arr.length && !func(arr[0])) {\n arr.shift();\n }\n return arr;\n}"
+ "function dropElements(arr, func) {\n // Drop them elements.\n while (arr.length && !func(arr[0])) {\n arr.shift();\n }\n return arr;\n}"
],
"tests": [
- "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n >= 3;}), [3, 4], 'message: drop([1, 2, 3, 4], function(n) {return n >= 3;})
should return [3, 4]
.');",
- "assert.deepEqual(drop([0, 1, 0, 1], function(n) {return n === 1;}), [1, 0, 1], 'message: drop([0, 1, 0, 1], function(n) {return n === 1;})
should return [1, 0, 1]
.');",
- "assert.deepEqual(drop([1, 2, 3], function(n) {return n > 0;}), [1, 2, 3], 'message: drop([1, 2, 3], function(n) {return n > 0;})
should return [1, 2, 3]
.');",
- "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n > 5;}), [], 'message: drop([1, 2, 3, 4], function(n) {return n > 5;})
should return []
.');",
- "assert.deepEqual(drop([1, 2, 3, 7, 4], function(n) {return n > 3;}), [7, 4], 'message: drop([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return [7, 4]
.');",
- "assert.deepEqual(drop([1, 2, 3, 9, 2], function(n) {return n > 2;}), [3, 9, 2], 'message: drop([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return [3, 9, 2]
.');"
+ "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}), [3, 4], 'message: dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
should return [3, 4]
.');",
+ "assert.deepEqual(dropElements([0, 1, 0, 1], function(n) {return n === 1;}), [1, 0, 1], 'message: dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return [1, 0, 1]
.');",
+ "assert.deepEqual(dropElements([1, 2, 3], function(n) {return n > 0;}), [1, 2, 3], 'message: dropElements([1, 2, 3], function(n) {return n > 0;})
should return [1, 2, 3]
.');",
+ "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n > 5;}), [], 'message: dropElements([1, 2, 3, 4], function(n) {return n > 5;})
should return []
.');",
+ "assert.deepEqual(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}), [7, 4], 'message: dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return [7, 4]
.');",
+ "assert.deepEqual(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}), [3, 9, 2], 'message: dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return [3, 9, 2]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -842,21 +842,21 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function steamroller(arr) {",
+ "function steamrollArray(arr) {",
" // I'm a steamroller, baby",
" return arr;",
"}",
"",
- "steamroller([1, [2], [3, [[4]]]]);"
+ "steamrollArray([1, [2], [3, [[4]]]]);"
],
"solutions": [
- "function steamroller(arr) {\n if (!Array.isArray(arr)) {\n return [arr];\n }\n var out = [];\n arr.forEach(function(e) {\n steamroller(e).forEach(function(v) {\n out.push(v);\n });\n });\n return out;\n}"
+ "function steamrollArray(arr) {\n if (!Array.isArray(arr)) {\n return [arr];\n }\n var out = [];\n arr.forEach(function(e) {\n steamrollArray(e).forEach(function(v) {\n out.push(v);\n });\n });\n return out;\n}"
],
"tests": [
- "assert.deepEqual(steamroller([[[\"a\"]], [[\"b\"]]]), [\"a\", \"b\"], 'message: steamroller([[[\"a\"]], [[\"b\"]]])
should return [\"a\", \"b\"]
.');",
- "assert.deepEqual(steamroller([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'message: steamroller([1, [2], [3, [[4]]]])
should return [1, 2, 3, 4]
.');",
- "assert.deepEqual(steamroller([1, [], [3, [[4]]]]), [1, 3, 4], 'message: steamroller([1, [], [3, [[4]]]])
should return [1, 3, 4]
.');",
- "assert.deepEqual(steamroller([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'message: steamroller([1, {}, [3, [[4]]]])
should return [1, {}, 3, 4]
.');"
+ "assert.deepEqual(steamrollArray([[[\"a\"]], [[\"b\"]]]), [\"a\", \"b\"], 'message: steamrollArray([[[\"a\"]], [[\"b\"]]])
should return [\"a\", \"b\"]
.');",
+ "assert.deepEqual(steamrollArray([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'message: steamrollArray([1, [2], [3, [[4]]]])
should return [1, 2, 3, 4]
.');",
+ "assert.deepEqual(steamrollArray([1, [], [3, [[4]]]]), [1, 3, 4], 'message: steamrollArray([1, [], [3, [[4]]]])
should return [1, 3, 4]
.');",
+ "assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'message: steamrollArray([1, {}, [3, [[4]]]])
should return [1, {}, 3, 4]
.');"
],
"type": "bonfire",
"MDNlinks": [
@@ -926,26 +926,26 @@
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function every(collection, pre) {",
+ "function truthCheck(collection, pre) {",
" // Is everyone being true?",
" return pre;",
"}",
"",
- "every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\");"
+ "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\");"
],
"solutions": [
- "function every(collection, pre) {\n // Does everyone have one of these?\n return collection.every(function(e) { return e[pre]; });\n}"
+ "function truthCheck(collection, pre) {\n // Does everyone have one of these?\n return collection.every(function(e) { return e[pre]; });\n}"
],
"tests": [
- "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), true, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.');",
- "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), false, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.');",
- "assert.strictEqual(every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 2}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\"), false, 'message: every([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.');",
- "assert.strictEqual(every([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\"), false, 'message: every([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false');",
- "assert.strictEqual(every([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\"), true, 'message: every([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true');",
- "assert.strictEqual(every([{\"single\": \"yes\"}], \"single\"), true, 'message: every([{\"single\": \"yes\"}], \"single\")
should return true');",
- "assert.strictEqual(every([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\"), false, 'message: every([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false');",
- "assert.strictEqual(every([{\"single\": \"double\"}, {\"single\": undefined}], \"single\"), false, 'message: every([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false');",
- "assert.strictEqual(every([{\"single\": \"double\"}, {\"single\": NaN}], \"single\"), false, 'message: every([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false');"
+ "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), true, 'message: truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.');",
+ "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), false, 'message: truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.');",
+ "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 2}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\"), false, 'message: truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.');",
+ "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\"), false, 'message: truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false');",
+ "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\"), true, 'message: truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true');",
+ "assert.strictEqual(truthCheck([{\"single\": \"yes\"}], \"single\"), true, 'message: truthCheck([{\"single\": \"yes\"}], \"single\")
should return true');",
+ "assert.strictEqual(truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\"), false, 'message: truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false');",
+ "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\"), false, 'message: truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false');",
+ "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\"), false, 'message: truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false');"
],
"isRequired": true,
"type": "bonfire",
@@ -968,29 +968,29 @@
"title": "Arguments Optional",
"description": [
"Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.",
- "For example, add(2, 3)
should return 5
, and add(2)
should return a function.",
+ "For example, addTogether(2, 3)
should return 5
, and addTogether(2)
should return a function.",
"Calling this returned function with a single argument will then return the sum:",
- "var sumTwoAnd = add(2);
",
+ "var sumTwoAnd = addTogether(2);
",
"sumTwoAnd(3)
returns 5
.",
"If either argument isn't a valid number, return undefined.",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
- "function add() {",
+ "function addTogether() {",
" return false;",
"}",
"",
- "add(2,3);"
+ "addTogether(2,3);"
],
"solutions": [
- "function add() {\n var a = arguments[0];\n if (toString.call(a) !== '[object Number]') return; \n if (arguments.length === 1) {\n return function(b) {\n if (toString.call(b) !== '[object Number]') return;\n return a + b;\n };\n }\n var b = arguments[1];\n if (toString.call(b) !== '[object Number]') return; \n return a + arguments[1];\n}"
+ "function addTogether() {\n var a = arguments[0];\n if (toString.call(a) !== '[object Number]') return; \n if (arguments.length === 1) {\n return function(b) {\n if (toString.call(b) !== '[object Number]') return;\n return a + b;\n };\n }\n var b = arguments[1];\n if (toString.call(b) !== '[object Number]') return; \n return a + arguments[1];\n}"
],
"tests": [
- "assert.deepEqual(add(2, 3), 5, 'message: add(2, 3)
should return 5.');",
- "assert.deepEqual(add(2)(3), 5, 'message: add(2)(3)
should return 5.');",
- "assert.isUndefined(add(\"http://bit.ly/IqT6zt\"), 'message: add(\"http://bit.ly/IqT6zt\")
should return undefined.');",
- "assert.isUndefined(add(2, \"3\"), 'message: add(2, \"3\")
should return undefined.');",
- "assert.isUndefined(add(2)([3]), 'message: add(2)([3])
should return undefined.');"
+ "assert.deepEqual(addTogether(2, 3), 5, 'message: addTogether(2, 3)
should return 5.');",
+ "assert.deepEqual(addTogether(2)(3), 5, 'message: addTogether(2)(3)
should return 5.');",
+ "assert.isUndefined(addTogether(\"http://bit.ly/IqT6zt\"), 'message: addTogether(\"http://bit.ly/IqT6zt\")
should return undefined.');",
+ "assert.isUndefined(addTogether(2, \"3\"), 'message: addTogether(2, \"3\")
should return undefined.');",
+ "assert.isUndefined(addTogether(2)([3]), 'message: addTogether(2)([3])
should return undefined.');"
],
"type": "bonfire",
"MDNlinks": [