Skip to content

Instantly share code, notes, and snippets.

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

DT Stanley dtstanley

🏠
Working from home
  • Wilmington, DE
View GitHub Profile
@dtstanley
dtstanley / fizzBuzzDrillJS.js
Created June 10, 2017 01:58 — forked from anonymous/fizzBuzzDrillJS.js
fizzBuzzDrillJS created by dtstanley - https://repl.it/G9KW/272
function fizzBuzz(countTo) {
var newCountTo = [];
for (var i =1; i<= countTo; i++){
// if (i%3 !==0 && i%5 !==0){
// newCountTo.push(i);
// }
//compare countTo[i] to 15 and chg countTo[i] to fizzBuzz
if (i%3 ===0 && i%5 ===0){
@dtstanley
dtstanley / fizzBuzzDrillJS2.js
Created June 9, 2017 23:06 — forked from anonymous/fizzBuzzDrillJS2.js
fizzBuzzDrillJS2 created by dtstanley - https://repl.it/Ieut/9
function fizzBuzz(countTo) {
console.log("initial countTo = ", countTo);
var newCountTo = [];
for (var i =0; i< countTo.length; i++){
//compare countTo[i] to 15 and chg countTo[i] to fizzBuzz
if (countTo[i]%3 ==0 && countTo[i]%5 ==0){
newCountTo[i] = 'fizzbuzz';
}
@dtstanley
dtstanley / fizzBuzzDrillJS.js
Created June 9, 2017 21:37 — forked from anonymous/fizzBuzzDrillJS.js
fizzBuzzDrillJS created by dtstanley - https://repl.it/G9KW/266
function fizzBuzz(countTo) {
var newCountTo = [];
for (var i =1; i<= countTo.length; i++){
//compare countTo[i] to 3 and chg countTo[i] to fizz
if (countTo[i]%3 ===0){
newCountTo[i] = 'fizz';
}
//compare countTo[i] to 5 and chg countTo[i] to buzz
if (countTo[i]%5 ===0){
@dtstanley
dtstanley / computeAveDrillJS.js
Last active June 9, 2017 21:11 — forked from anonymous/computeAveDrillJS.js
computeAveDrillJS created by dtstanley - https://repl.it/G9KO/135
function average(numbers) {
//Performing task without looping:
// return (numbers.reduce(function sum(total, num){
// return total + num;
// })/numbers.length);
// Second way to perform with loop
var maxNum = numbers[0];
for (var i =1; i<= numbers.length -1; i++){
maxNum += numbers[i];
@dtstanley
dtstanley / computeAveDrillJS.js
Created June 9, 2017 20:45 — forked from anonymous/computeAveDrillJS.js
computeAveDrillJS created by dtstanley - https://repl.it/G9KO/126
function average(numbers) {
return (numbers.reduce(function sum(total, num){
return total + num;
})/numbers.length);
}
/* From here down, you are not expected to
understand.... for now :)
@dtstanley
dtstanley / minMaxdrillJS.js
Created June 9, 2017 20:19 — forked from anonymous/minMaxdrillJS.js
minMaxdrillJS created by dtstanley - https://repl.it/G9KJ/199
function max(numbers) {
var maxNum = 0;
for (var i =1; i<= numbers.length; i++){
if (maxNum <= numbers[i]){maxNum = numbers[i];
}
}
return maxNum;
}
@dtstanley
dtstanley / filterDrillJS.js
Created June 9, 2017 16:25 — forked from anonymous/filterDrillJS.js
filterDrillJS created by dtstanley - https://repl.it/G9Hd/98
function shortWords(array) {
return array.filter(function lessFive(x){
return x.length <5;
});
}
@dtstanley
dtstanley / findDrillJS.js
Created June 9, 2017 15:45 — forked from anonymous/findDrillJS.js
findDrillJS created by dtstanley - https://repl.it/G9Hl/80
function divisibleBy5(array) {
return array.find(function fiveDiv(x){
return x % 5===0;
});
}
/* From here down, you are not expected to
understand.... for now :)
@dtstanley
dtstanley / sortDrillJS.js
Created June 9, 2017 15:17 — forked from anonymous/sortDrillJS.js
sortDrillJS created by dtstanley - https://repl.it/G9H5/107
function greatestToLeast(array) {
//array.sort(function(a, b) { return b-a; }); descending order
return array.sort(function(a,b){
return b-a;
});
}
@dtstanley
dtstanley / squareMapJS.js
Created June 9, 2017 14:45 — forked from anonymous/squareMapJS.js
squareMapJS created by dtstanley - https://repl.it/G9HI/139
function squares(array) {
return array.map(function(x){
return Math.pow(x,2);
})
}