This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Pairwise | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-pairwise | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function pairwise(arr, arg) { | |
| var used = []; | |
| for (var i = 0; i < arr.length - 1; i++) { | |
| if (used.indexOf(i) === -1) { | |
| for (var j = i + 1; j < arr.length; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Map the Debris | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-map-the-debris | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function orbitalPeriod(arr) { | |
| var GM = 398600.4418; | |
| var earthRadius = 6367.4447; | |
| var results = []; | |
| for(var i = 0; i < arr.length; i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Steamroller | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-steamroller# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function steamroller(arr) { | |
| var flat = []; | |
| for (var i =0; i < arr.length; i++) { | |
| if (Array.isArray(arr[i])) { | |
| var flattened = steamroller(arr[i]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Everything Be True | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-everything-be-true# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function every(collection, pre) { | |
| for (var i = 0; i < collection.length; i++) { | |
| if (!collection[i][pre]) { | |
| return false; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Sum All Primes | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-primes# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function sumPrimes(num) { | |
| var primes = []; | |
| for (var trial = 2; trial <= num; trial++) { | |
| var isPrime = true; | |
| for (var prime = 0; prime < primes.length; prime++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Make a Person | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-make-a-person# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| var Person = function(firstAndLast) { | |
| var firstName = firstAndLast.split(' ')[0]; | |
| var lastName = firstAndLast.split(' ')[1]; | |
| this.getFirstName = function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Smallest Common Multiple | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function smallestCommons(arr) { | |
| var lbound = Math.min(arr[0], arr[1]); | |
| var ubound = Math.max(arr[0], arr[1]); | |
| var multiple = 0; | |
| var multipleFound = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Arguments Optional | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-arguments-optional | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function add() { | |
| if (typeof arguments[0] !== "number") { | |
| return undefined; | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Binary Agents | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-binary-agents | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function binaryAgent(str) { | |
| var numbers = str.split(' '); | |
| var output = ''; | |
| for (var i = 0; i < numbers.length; i++) { | |
| var charCode = parseInt(numbers[i], 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Bonfire: Drop it | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-drop-it | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function drop(arr, func) { | |
| if (arr.length === 0 || func(arr[0])) { | |
| return arr; | |
| } | |
| arr.shift(); |
NewerOlder