Skip to content

Instantly share code, notes, and snippets.

View mattnwa's full-sized avatar
🏠
Working from home

Matt Luker mattnwa

🏠
Working from home
  • Bentonville, Ar
View GitHub Profile
@mattnwa
mattnwa / index.html
Last active August 29, 2015 14:28
jQuery Social Comment Example
<body>
<div class="header">
<h2>Social Status Update Example</h2>
<h5>Using jQuery to add posts and remove on click. By Matt Luker </h5>
</div>
<div class="container">
<form>
<div class="form-group">
<textarea class="form-control status-box" rows="2" placeholder="What's on your mind?"></textarea>
</div>
// Bonfire: Reverse a String
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-reverse-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function reverseString(str) {
var result = str.split('').reverse();
return result.join('');
}
// Bonfire: Check for Palindromes
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-check-for-palindromes
// Learn to Code at Free Code Camp (www.freecodecamp.com)
//Steps to think through..
// 1. we need to remove unneeded whitespace/numbers and whitespace. Needs to be lower case.
// 2. Need to then create another variable with the string turned into an array and reverse joined.
// 3. Compare the two created strings to see if they match. return F/A statement.
// Bonfire: Find the Longest Word in a String
// Author: @mattnwa
// 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) {
strSplit = str.split(' ');
var longest = 0;
for(var i =0; strSplit.length >i; i++){
// Bonfire: Title Case a Sentence
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function titleCase(str) {
strLowercase = str.toLowerCase().split(' ');
for (var i =0; i <strLowercase.length; i++){
strLowercase[i] = strLowercase[i].split('');
strLowercase[i][0] = strLowercase[i][0].toUpperCase();
// Bonfire: Truncate a string
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function truncate(str, num) {
// Clear out that junk in your trunk
if (num <=3) {
return str.slice(0, num) + "...";
// Bonfire: Chunky Monkey
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-chunky-monkey
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function chunk(arr, size) {
var temp = [];
for(var i = 0; i < arr.length; i){
temp.push(arr.slice(i, i+=size));
// Bonfire: Slasher Flick
// Author: @mattnwa
// 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
if (howMany < 1) {
return arr;
} else {
// Bonfire: Mutations
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var elem0 = arr[0].toLowerCase();
var elem1 = arr[1].toLowerCase();
for(var i = 0; i < elem1.length; i++){
// Bonfire: Falsy Bouncer
// Author: @mattnwa
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr.filter(Boolean);
}