Skip to content

Instantly share code, notes, and snippets.

View robertsheacole's full-sized avatar

Shea Cole robertsheacole

  • Randall Reilly
  • Tuscaloosa, AL
View GitHub Profile
// Bonfire: Title Case a Sentence
// Author: @robertsheacole
// 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 string lowercase and split into array
var makeArray = str.toLowerCase().split(' ');
//loop through array
for ( var i = 0; i < makeArray.length; i++){
// Bonfire: Find the Longest Word in a String
// Author: @robertsheacole
// 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) {
//split string into array
var stringToArray = str.split(' ');
var longestWord = 0;
//loop through the array and get the length of first item
// Bonfire: Check for Palindromes
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function palindrome(str) {
// Good luck!
var before = str.toLowerCase().replace( /[\W_]+/g, "");
var after = before.split('').reverse().join('');
// Bonfire: Factorialize a Number
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-factorialize-a-number
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function factorialize(num) {
//Check is num paramater is equal to 0. If so return 1, otherwise answer will be 0.
if(num === 0){
return 1;
}