Skip to content

Instantly share code, notes, and snippets.

View jwgoedert's full-sized avatar

James Wesley Goedert jwgoedert

View GitHub Profile
@jwgoedert
jwgoedert / jsbin.nohoki.js
Last active January 30, 2017 23:56 — forked from anonymous/index.html
Each!
/*each takes an array and a callback function which passes
(value, index, collection) as its arguments. Each works on
both arrays and objects and does not work with a return within
the body.
*/
_.each = function each(collection, myFunction){
if(_.typeOf(collection) === 'array'){
for(var i = 0; i < collection.length; i++){
myFunction(collection[i], i, collection);
}
@jwgoedert
jwgoedert / jsbin.dipume.js
Last active January 30, 2017 21:18 — forked from anonymous/index.html
Last!
_.last = function last(arr, number){
var newArr = [];
if(!Array.isArray(arr)){
return [];
}else if(isNaN(number) || number === undefined ){
return arr[arr.length - 1];
}else if(number < 0){
return newArr;
}else if(number > arr.length){
return arr;
@jwgoedert
jwgoedert / jsbin.gixafoh.js
Last active January 30, 2017 21:07 — forked from anonymous/index.html
First!
//first takes an array and a number and returns that amount
//of values from the beginning of an array in a new array.
_.first = function first(arr, number){
var newArr = [];
if(!Array.isArray(arr)){
return [];
}else if(isNaN(number) || number === undefined ){
return arr[0];
}else if(number < 0){
//takes any value and returns that value's type as a string
_.typeOf = function typeOf (anything){
if(anything === null) {
return anything = "null";
}else if(Array.isArray(anything)){
return "array";
}
return typeof anything;
}
//typeOf with them arrows!!
@jwgoedert
jwgoedert / jsbin.bemehi.js
Last active January 30, 2017 21:26 — forked from anonymous/index.html
JS Bin// source http://jsbin.com/bemehi
//identity- takes any value and returns that exact value.
_.identity = function identity(anything) {
return anything;
};
//using arrow fun... so clean
identity = (val) => val;
/*Variables-our friends in the age of repetition
Variables are placeholders which allow programs to easily recall
information or actions, alter them, and implement complex operations
in a clear concise manner. They can be thought of as containers for
holding values of any data type including numbers, strings, booleans,
and even functions or objects.
*/
/*declaring a variable called num1 with "var" keyword
this simply creates a place in memory which can then be assigned to
@jwgoedert
jwgoedert / jsbin.rekikud.js
Last active January 17, 2017 20:48 — forked from anonymous/index.html
JS Binfunctions// source http://jsbin.com/rekikud
//Functions: programs within programs.
//a dream within a dream
//two phases of functions are declaration and invocation(or calling)
// declaration (anonymous function being declared as variable)
//
var fullName = function(first, middle, last){
var person = {
FirstName: first,
MiddleName: middle,
Last: last
@jwgoedert
jwgoedert / jsbin.mutivuq.js
Last active January 17, 2017 20:39 — forked from anonymous/index.html
JS Binloops// source http://jsbin.com/mutivuq
// Loops: while, for, for in.
// Making your way through the world today.
// while loops address a condition and execute the code within {} as
// long as that statement holds true
"use strict";
var x = 0;
while (x === 0) {}
//console.log("we're ready for something");
@jwgoedert
jwgoedert / jsbin.rekikud.js
Last active January 30, 2017 20:49 — forked from anonymous/index.html
JS Binfunctions// source http://jsbin.com/rekikud
//Functions: programs within programs.
//a dream within a dream
var fullName = function(first, middle, last){
var person = {
FirstName: first,
MiddleName: middle,
Last: last
}
var newName = first + " " + middle + " " +last;
console.log(newName);
@jwgoedert
jwgoedert / jsbin.mutivuq.js
Last active January 30, 2017 20:50 — forked from anonymous/index.html
JS Binloops// source http://jsbin.com/mutivuq
// Loops: while, for, for in.
// Making your way through the world today.
// while loops address a condition and execute the code within {} as
// long as that statement holds true
"use strict";
var x = 0;
while (x === 0) {
console.log("we're ready for something");
}