diff --git a/challenges/upper-intermediate-bonfires.json b/challenges/upper-intermediate-bonfires.json index c09cb30da4..b4ab210cd2 100644 --- a/challenges/upper-intermediate-bonfires.json +++ b/challenges/upper-intermediate-bonfires.json @@ -39,6 +39,9 @@ "Closures", "Details of the Object Model" ], + "solutions": [ + "var Person = function(firstAndLast) {\n\n var firstName, lastName;\n\n function updateName(str) { \n firstName = str.split(\" \")[0];\n lastName = str.split(\" \")[1]; \n }\n\n updateName(firstAndLast);\n\n this.getFirstName = function(){\n return firstName;\n };\n \n this.getLastName = function(){\n return lastName;\n };\n \n this.getFullName = function(){\n return firstName + \" \" + lastName;\n };\n \n this.setFirstName = function(str){\n firstName = str;\n };\n \n\n this.setLastName = function(str){\n lastName = str;\n };\n \n this.setFullName = function(str){\n updateName(str);\n };\n};\n\nvar bob = new Person('Bob Ross');\nbob.getFullName();" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -80,6 +83,9 @@ "MDNlinks": [ "Math.pow()" ], + "solutions": [ + "function orbitalPeriod(arr) {\n var GM = 398600.4418;\n var earthRadius = 6367.4447;\n var TAU = 2 * Math.PI; \n return arr.map(function(obj) {\n return {\n name: obj.name,\n orbitalPeriod: Math.round(TAU * Math.sqrt(Math.pow(obj.avgAlt+earthRadius, 3)/GM))\n };\n });\n}\n\norbitalPeriod([{name : \"sputkin\", avgAlt : 35873.5553}]);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -120,6 +126,9 @@ "Array.reduce()" ], "type": "bonfire", + "solutions": [ + "function pairwise(arr, arg) {\n var sum = 0;\n arr.forEach(function(e, i, a) {\n if (e != null) { \n var diff = arg-e;\n a[i] = null;\n var dix = a.indexOf(diff);\n if (dix !== -1) {\n sum += dix;\n sum += i;\n a[dix] = null;\n } \n }\n });\n return sum;\n}\n\npairwise([1,4,2,3,0,5], 7);\n" + ], "challengeType": 5, "nameCn": "", "descriptionCn": [],