#FreeCodeCamp Bonfire: Return Largest Numbers in Arrays

function largestOfFour(arr) {
  return arr.map(function(num) {
    return Math.max.apply(null, num);
  });
}

largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);

 

Advertisements

#FreeCodeCamp Bonfire: Title Case a Sentence

function titleCase(str) {
  str = str.replace(/wS*/g, function(str){return str.charAt(0).toUpperCase() + str.substr(1).toLowerCase();});
  return str;
}

titleCase("I'm a little tea pot");

 

#FreeCodeCamp Bonfire: Check for Palindromes

function palindrome(str) {
  // Good luck!
  var strippedString = str.toLowerCase().replace(/W|_/g,'');
  var reverseString = strippedString.split("").reverse().join("");
  if (reverseString === strippedString) {
    return true;
  }
  else {
    return false;
  }
}



palindrome("eye");