Skip to content

Commit

Permalink
Merge pull request freeCodeCamp#3835 from FreeCodeCamp/feature/solutions
Browse files Browse the repository at this point in the history
Add solutions to upper intermediate bonfires
  • Loading branch information
Berkeley Martinez committed Oct 22, 2015
2 parents 2c33a1e + 5105efa commit d29d340
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/models/challenge.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
},
"descriptionPt": {
"type": "array"
},
"solutions": {
"type": "array",
"default": []
}
},
"validations": [],
Expand Down
9 changes: 9 additions & 0 deletions seed/challenges/upper-intermediate-bonfires.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": "",
Expand Down Expand Up @@ -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": [],
Expand Down

0 comments on commit d29d340

Please sign in to comment.