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: Spinal Tap Case | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-spinal-tap-case | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
//Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes. | |
function spinalCase(str) { | |
// "It's such a fine line between stupid, and clever." | |
// --David St. Hubbins | |
// Create a variable for the white space and underscores. |
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: Convert HTML Entities | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-convert-html-entities | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
/* Convert the characters "&", "<", ">", '"' (double quote), and "'" (apostrophe), in a string to their corresponding HTML entities. */ | |
function convert(str) { | |
// :) | |
// Split by character to avoid problems. |
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: Sorted Union | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-sorted-union | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
/* Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays. | |
In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array. | |
The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order. */ |
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: Boo who | |
// Author: @nirajkrz | |
// 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. | |
//Check if a value is classified as a boolean primitive. Return true or false. | |
return typeof bool === '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: Missing letters | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-missing-letters | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function fearNotLetter(str) { | |
// Create our variables. | |
var firstCharacter = str.charCodeAt(0); | |
var valueToReturn = ''; | |
var secondCharacter = ''; |
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: DNA Pairing | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-dna-pairing | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function pair(str) { | |
/*The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array. | |
Base pairs are a pair of AT and CG. Match the missing element to the provided character. |
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: Pig Latin | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-pig-latin | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function translate(str) { | |
// Create variables to be used | |
var pigLatin = ''; | |
var regex = /[aeiou]/gi; | |
// Check if the first character is a vowel |
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: Search and Replace | |
// Author: @nirajkrz | |
// 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) { | |
// Find index where before is on string | |
var index = str.indexOf(before); | |
// Check to see if the first letter is uppercase or not | |
if (str[index] === str[index].toUpperCase()) { |
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: Where art thou | |
// Author: @nirajkrz | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-art-thou | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function where(collection, source) { | |
var arr = []; | |
// What's in a name? | |
var keys = Object.keys(source); | |
// Filter array and remove the ones that do not have the keys from source. |
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: Roman Numeral Converter | |
// Author: @nirajkrz | |
// 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) | |
return false; | |
var digits = String(+num).split(""), | |
key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM", |