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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-everything-be-true | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function every(collection, pre) { | |
// Is everyone being true? | |
var returnVal = true; | |
collection.forEach(function(x){ | |
console.log(x.hasOwnProperty(pre)); |
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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-binary-agents | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function binaryAgent(str) { | |
return String.fromCharCode(...str.split(" ").map(function(char){ return parseInt(char, 2); })); | |
} | |
binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111"); |
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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-steamroller | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function steamroller(arr) { | |
// I'm a steamroller, baby | |
var newArr = []; | |
var flatten = function(x){ | |
if(!Array.isArray(x)){ |
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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-drop-it | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function drop(arr, func) { | |
// Drop them elements. | |
while(!func(arr[0])){ | |
arr.shift(); | |
} |
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: Finders Keepers | |
// Author: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-finders-keepers | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function find(arr, func) { | |
newArr = arr.filter(func); | |
return newArr[0]; | |
} |
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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-smallest-common-multiple | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function smallestCommons(arr) { | |
range = toRange(arr); | |
return range.reduce(function(a, b) { | |
return lcm(a, b); | |
}); |
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: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-primes | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function sumPrimes(num) { | |
if(num === 1){ | |
return 0; | |
} | |
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 Odd Fibonacci Numbers | |
// Author: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-odd-fibonacci-numbers | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function sumFibs(num) { | |
var a = 0, b = 1, c = 1, sum = 0; | |
var arr = [0]; |
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: Spinal Tap Case | |
// Author: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function spinalCase(str) { | |
return str.replace(/([a-z])([A-Z])/g, '$1 $2').replace(/\s+|_+/g, '-').toLowerCase(); | |
} |
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: Convert HTML Entities | |
// Author: @patrickcurl | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-convert-html-entities | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function convert(str) { | |
// :) | |
var arr = str.split(""); | |
arr.forEach(function(x,y){ | |
if(x === "&"){ |
NewerOlder