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: Sorted Union | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-sorted-union | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function unite() { | |
| var myArray = []; | |
| for (var i = 0; i < arguments.length; i++) { | |
| for (var j = 0; j < arguments[i].length; j++) { | |
| if (myArray.indexOf(arguments[i][j]) < 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: Boo who | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-boo-who | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function boo(bool) { | |
| // What is the new fad diet for ghost developers? The Boolean. | |
| if(typeof bool === "boolean"){ | |
| return true; | |
| } |
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: Missing letters | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-missing-letters | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function fearNotLetter(str) { | |
| for(var i=0;i<str.length;i++){ | |
| var letter = str.charCodeAt(i); | |
| if(letter !== str.charCodeAt(0) + 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: DNA Pairing | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function pair(str) { | |
| var dna = str.split(""); | |
| var pairs = []; | |
| dna.forEach(function(x){ | |
| if(x === "G"){ pairs.push(["G","C"]);} |
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: Pig Latin | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-pig-latin | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function translate(str) { | |
| var first = str.charAt(0); | |
| var cluster = str.charAt(0) + str.charAt(1); | |
| startsWithVowel = 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: Search and Replace | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-search-and-replace | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function myReplace(str, before, after) { | |
| arr = str.split(" "); | |
| arr.forEach(function(x,y){ | |
| if(x == before){ |
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: Where art thou | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-where-art-thou | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function where(collection, source) { | |
| // "What's in a name? that which we call a rose | |
| var sourceKeys = Object.keys(source); | |
| return collection.filter(function (o) { |
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: Roman Numeral Converter | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-roman-numeral-converter | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function convert(num) { | |
| if(num < 1){ return "";} | |
| if(num >= 1000){return "M" + convert(num-1000);} | |
| if(num >= 900){ return "CM" + convert(num-900);} | |
| if(num >= 500){return "D" + convert(num-500);} |
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 Numbers in a Range | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-sum-all-numbers-in-a-range | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function sumAll(arr) { | |
| var newArr = []; | |
| for(var i=Math.min(...arr); i<=Math.max(...arr); i++){ | |
| newArr.push(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: Diff Two Arrays | |
| // Author: @patrickcurl | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-diff-two-arrays | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function diff(arr1, arr2) { | |
| var newArr = []; | |
| arr1.forEach(function(a){ | |
| if(arr2.indexOf(a) == -1){ | |
| newArr.push(a); |