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: Falsy Bouncer | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function bouncer(arr) { | |
| function isFalse(value){ | |
| //look at the variables and only return the ones that aren't false | |
| switch(value){ | |
| case 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: Mutations | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function mutation(arr) { | |
| var wordToSearchIn = arr.shift(); | |
| var seedWord = arr[0]; | |
| //Loop through each letter of first word | |
| for(var i = 0; i < seedWord.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: Slasher Flick | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function slasher(arr, howMany) { | |
| // it doesn't always pay to be first | |
| for(var i = 0; i < howMany; i++){ | |
| 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: Chunky Monkey | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function chunk(arr, size) { | |
| var chunkedArray = []; | |
| var count = 0; | |
| var newArray = []; | |
| 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: Truncate a string | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function truncate(str, num) { | |
| var dots = ''; | |
| if(num>3){ | |
| dots = '...'; | |
| } |
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: Repeat a string repeat a string | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function repeat(str, num) { | |
| var stringToReturn = ''; | |
| for(var i = 0; i < num; i++){ | |
| stringToReturn += str; | |
| }; |
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: Confirm the Ending | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function end(str, target) { | |
| // count the number of charachters in target | |
| //count backwards from the end of the string str and then compare that to target | |
| var targetCount = target.length; | |
| var textToCompare = str.substr((str.length - targetCount),str.length); |
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: Return Largest Numbers in Arrays | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function largestOfFour(arr) { | |
| //initialize the array to return from the function | |
| var arrayToReturn = []; | |
| //loop through main array | |
| 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: Title Case a Sentence | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function titleCase(str) { | |
| //make everything lowercase | |
| str = str.toLowerCase(); | |
| //break sentence into array | |
| var stringArray = str.split(' '); |
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: Find the Longest Word in a String | |
| // Author: @goteamtim | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-find-the-longest-word-in-a-string | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function findLongestWord(str) { | |
| var longestWord = 0; | |
| var sentenceArray = str.split(' '); | |
| longestWord = sentenceArray[0].length; | |
| sentenceArray.map(function(x){ |
NewerOlder