This file contains 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
// Object initialiser or literal | |
{ [ nameValuePair1[, nameValuePair2[, ...nameValuePairN] ] ] } | |
// Called as a constructor | |
new Object([value]) |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function bouncer(arr) { | |
//Based on the MDN document this will Boolean function will include all falsy values | |
//I can just filter all of them with filter function! | |
return arr.filter(Boolean); | |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function mutation(arr) { | |
var stringToArray1 = arr[0].toLowerCase().split(""); //h,e,l,l,o | |
var stringToArray2 = arr[1].toLowerCase().split(""); //h,e,y | |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function truncate(str, num) { | |
if(str.length > num && num > 3){ | |
return str.slice(0, num - 3) + "..."; | |
} |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function slasher(arr, howMany) { | |
if(howMany < arr.length){ | |
var chop = arr.splice(0, howMany); | |
return arr; |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function end(str, target) { | |
//I used a conditional to check if str (string) has the requested ending letter or word | |
//The target is the requested letter or word which is being called below | |
if(str.substr(-target.length) == target){ | |
return true; |
This file contains 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: @dbess1 | |
// 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) { | |
var numbers = []; | |
for(var i = 0; i < arr.length; i++){ //for iterating through the large array | |
var biggestNumber = 0; | |
for(var j = 0; j < arr[i].length; j++){ //for iterating through the sub-arrays |
This file contains 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: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function titleCase(str) { | |
return str.toLowerCase().replace(/^[a-z]|\s[a-z]/g, function(i){ return i.toUpperCase(); } ); | |
} | |
titleCase("I'm a little tea pot"); |
This file contains 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: @dbess1 | |
// 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 allWords = str.split(" "); | |
var biggestWords = 0; | |
This file contains 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: Check for Palindromes | |
// Author: @dbess1 | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function palindrome(str) { | |
var word = str.toLowerCase().replace(/[\W_]/g, ""); | |
var reversedWord = word.split("").reverse().join(""); | |
return word === reversedWord; | |
} |
NewerOlder