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: Where do I belong
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
//Push num into the arr array.
arr.push(num);
//Reorder arr from lowest to highest number.
arr.sort(function(a, b){
// Bonfire: Seek and Destroy
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
var args = arr.slice.call(arguments);
args.splice(0, 1);
var newArray = [];
for(var i = 0; i < arr.length; i++){
// Bonfire: Falsy Bouncer
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
function deleteFalsey(arr){
return Boolean(arr);
}
// Bonfire: Mutations
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var first = arr[0].toLowerCase().split('');
var query = arr[1].toLowerCase().split('');
for (var i = 0; i < query.length; i++){
// Bonfire: Slasher Flick
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
return arr.splice(howMany);
}
slasher([1, 2, 3], 2);
// Bonfire: Chunky Monkey
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
var newArray = [];
for(var i = 0; i < arr.length; i){
// Bonfire: Truncate a string
// Author: @robertsheacole
// 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 = "...";
var empty = "";
// Bonfire: Repeat a string repeat a string
// Author: @robertsheacole
// 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) {
if (num >= 0){
return str.repeat(num);
} else {
return "";
// Bonfire: Confirm the Ending
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function end(str, target)
{
str = str.split('');
if (str.length > 1){
// Bonfire: Return Largest Numbers in Arrays
// Author: @robertsheacole
// 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) {
//This array will hold our largest number at the end
var newArray = [];
//Loop through outer array (which contains 4 items - the number groups)
for(var i = 0; i < arr.length; i++){