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: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function bouncer(arr) { | |
| function filtMe(value){ | |
| var result=false; | |
| //NaN,undefined,null check only this way |
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: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function mutation(arr) { | |
| var result=true; | |
| var i=0; | |
| var arr1ToLower = arr[0].toLowerCase(); | |
| var arr2ToLower = arr[1].toLowerCase().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: Slasher Flick | |
| // Author: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function slasher(arr, howMany) { | |
| return arr.slice(howMany,arr.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: Chunky Monkey | |
| // Author: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function chunk(arr, size) { | |
| var subArr=[]; | |
| for (var i=0;i<arr.length;i=i+size){ | |
| subArr.push(arr.slice(i,i+size)); |
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: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function truncate(str, num) { | |
| return num>=str.length?str:str.substr(0,num-(num>=3?3: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: Repeat a string repeat a string | |
| // Author: @bskydive | |
| // 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) { | |
| // repeat after me | |
| return num<=0?'':str.repeat(num); | |
| } |
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: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function end(str, target) { | |
| return str.substr(-target.length,target.length)==target; | |
| } |
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: @bskydive | |
| // 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) { | |
| return arr.map(function (varArr){ | |
| return varArr.reduce(function(a,b){ | |
| return a>b?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: Title Case a Sentence | |
| // Author: @bskydive | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function titleCase(str) { | |
| var strToMasUpperCased=str.split(' ').map( | |
| function (val){ | |
| val=val.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: Find the Longest Word in a String | |
| // Author: @bskydive | |
| // 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 strToMasSorted=str.split(' ').sort(function compare(a,b){return a.length-b.length;}); | |
| return strToMasSorted[strToMasSorted.length-1].length; | |
| } |
NewerOlder