Skip to content

Instantly share code, notes, and snippets.

View liseferguson's full-sized avatar

Lise liseferguson

  • Portland, OR.
View GitHub Profile
@liseferguson
liseferguson / wisePerson.js
Created March 9, 2018 23:16
wisePerson generator
function wisePerson(wiseType, whatToSay) {
return `A wise ${wiseType} once said: "${whatToSay}".`;
}
// tests
function testWisePerson() {
const wiseType = 'goat';
@liseferguson
liseferguson / shouter.js
Created March 9, 2018 23:45
Shouter function (returns all caps)
function shouter(whatToShout) {
return `${whatToShout.toUpperCase()}!!!`;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@liseferguson
liseferguson / gist:3abd5622ff729ea9d9b76f8417fece28
Created March 10, 2018 00:01
Normalizer function (returns lowercase, trims whitespace before and after text in string)
function textNormalizer(text) {
return `${text.toLowerCase().trim()}`;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@liseferguson
liseferguson / area.js
Created March 10, 2018 01:12
Area function - Computes area of rectangle
function computeArea(width, height) {
return width* height;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@liseferguson
liseferguson / temps.js
Created March 10, 2018 01:28
Fahrenheit and Celcius temperature conversions
function celsToFahr(celsTemp) {
return celsTemp * 9/5 + 32;
}
function fahrToCels(fahrTemp) {
return (fahrTemp - 32) * 5/9;
}
/* From here down, you are not expected to
understand.... for now :)
function isDivisible(divisee, divisor) {
return divisee % divisor === 0;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
@liseferguson
liseferguson / index.js
Created March 11, 2018 17:22
Traffic Light Function drill
function doTrafficLights() {
const activeLight = getActiveLight();
if (activeLight === 'red') {
turnRed();
}
else if (activeLight === 'green') {
turnGreen();
}
else {
turnYellow();
@liseferguson
liseferguson / index.js
Created March 11, 2018 17:42
Error message drill
function main() {
try {
doAllTheThings();
}
catch(err) {
console.error(err);
reportError(err);
}
}
@liseferguson
liseferguson / index.js
Created March 13, 2018 01:29
Accessing arrays
function addToList(list, item) {
list.push(item);
return list;
}
/* From here down, you are not expected to
understand.... for now :)
function findLength(array) {
return array.length;
}
function accessLastItem(array) {
return array[array.length - 1];
}
/* In the 2nd function, why is the array before the [array.length - 1] necessary?