Skip to content

Instantly share code, notes, and snippets.

View goteamtim's full-sized avatar

Tim Harshman goteamtim

  • Miva, Inc.
  • San Diego, CA
View GitHub Profile
anonymous
anonymous / bonfire-falsy-bouncer.js
Created December 11, 2015 17:17
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Falsy Bouncer
// Bonfire: Falsy Bouncer
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
function isFalse(value){
//look at the variables and only return the ones that aren't false
switch(value){
case false:
anonymous
anonymous / bonfire-mutations.js
Created December 11, 2015 05:36
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Mutations
// Bonfire: Mutations
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var wordToSearchIn = arr.shift();
var seedWord = arr[0];
//Loop through each letter of first word
for(var i = 0; i < seedWord.length; i++){
anonymous
anonymous / bonfire-slasher-flick.js
Created December 10, 2015 21:33
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Slasher Flick
// Bonfire: Slasher Flick
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
// it doesn't always pay to be first
for(var i = 0; i < howMany; i++){
arr.shift();
}
anonymous
anonymous / bonfire-chunky-monkey.js
Created December 10, 2015 21:14
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Chunky Monkey
// Bonfire: Chunky Monkey
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
var chunkedArray = [];
var count = 0;
var newArray = [];
for(var i = 0; i < arr.length; i++){
anonymous
anonymous / bonfire-truncate-a-string.js
Created December 9, 2015 22:35
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Truncate a string
// Bonfire: Truncate a string
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
var dots = '';
if(num>3){
dots = '...';
}
anonymous
anonymous / bonfire-repeat-a-string-repeat-a-string.js
Created December 9, 2015 21:31
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Repeat a string repeat a string
// Bonfire: Repeat a string repeat a string
// Author: @goteamtim
// 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) {
var stringToReturn = '';
for(var i = 0; i < num; i++){
stringToReturn += str;
};
anonymous
anonymous / bonfire-confirm-the-ending.js
Created December 9, 2015 21:20
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Confirm the Ending
// Bonfire: Confirm the Ending
// Author: @goteamtim
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target) {
// count the number of charachters in target
//count backwards from the end of the string str and then compare that to target
var targetCount = target.length;
var textToCompare = str.substr((str.length - targetCount),str.length);
anonymous
anonymous / bonfire-return-largest-numbers-in-arrays.js
Created December 9, 2015 20:29
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Return Largest Numbers in Arrays
// Bonfire: Return Largest Numbers in Arrays
// Author: @goteamtim
// 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) {
//initialize the array to return from the function
var arrayToReturn = [];
//loop through main array
for (var i = 0; i < arr.length; i++) {
anonymous
anonymous / bonfire-title-case-a-sentence.js
Created December 9, 2015 19:41
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Title Case a Sentence
// Bonfire: Title Case a Sentence
// Author: @goteamtim
// 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 everything lowercase
str = str.toLowerCase();
//break sentence into array
var stringArray = str.split(' ');
anonymous
anonymous / bonfire-find-the-longest-word-in-a-string.js
Created December 9, 2015 18:38
http://www.freecodecamp.com/goteamtim 's solution for Bonfire: Find the Longest Word in a String
// Bonfire: Find the Longest Word in a String
// Author: @goteamtim
// 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 longestWord = 0;
var sentenceArray = str.split(' ');
longestWord = sentenceArray[0].length;
sentenceArray.map(function(x){