Skip to content

Instantly share code, notes, and snippets.

@willwalker753
willwalker753 / Wiseperson generator drill
Created February 12, 2020 19:46
Wiseperson generator
function wisePerson(wiseType, whatToSay) {
let quote = 'A wise ' + wiseType + ' once said: "' + whatToSay + '."';
return quote;
}
/* From here down, you are not expected to
understand.... for now :)
Nothing to see here!
function shouter(whatToShout) {
let shout = whatToShout.toUpperCase();
shout = shout + '!!!';
return shout;
}
let whatToShout = ('as you can hear i am whispering');
console.log(shouter(whatToShout));
function testShouter() {
@willwalker753
willwalker753 / text normalizer drill
Created February 12, 2020 20:05
Text normalizer
function textNormalizer(text) {
let normal = text.toLowerCase();
normal = normal.trim();
return normal;
}
let text = " let's GO SURFING NOW everyone is learning how ";
console.log(textNormalizer(text));
function testTextNormalizer() {
@willwalker753
willwalker753 / area of a rectangle drill
Created February 12, 2020 21:26
Area of a Rectangle
function computeArea(width, height) {
let area = width*height;
return area
}
let width = 3;
let height = 4;
console.log(computeArea(width,height));
function testComputeArea() {
@willwalker753
willwalker753 / temperature conversion drill
Created February 12, 2020 21:34
Temperature conversion
function celsToFahr(celsTemp) {
let fahrenheit = (celsTemp * 9/5) + 32;
return fahrenheit;
}
function fahrToCels(fahrTemp) {
let celsius = (fahrTemp - 32)*(5/9);
return celsius;
}
@willwalker753
willwalker753 / Is divisible drill
Created February 12, 2020 21:42
Is divisible
function isDivisible(dividend, divisor) {
let rem = dividend % divisor;
let divisible = false;
if (rem === 0) {
divisible = true;
}
return divisible;
}
let dividend = 18;
@willwalker753
willwalker753 / gist:0e0b956843cf988c41e8b8b341e2b3d0
Created February 20, 2020 01:33
min and max (without sort) drill
function max(numbers) {
let maxnum = 0;
for (i = 0; i <= numbers.length; i++) {
if (maxnum < numbers[i]) {
maxnum = numbers[i];
}
}
if (numbers.length === 0) {
return null;
}
function average(numbers) {
let sum = numbers[0];
for (i=1; i<numbers.length; i++) {
sum += numbers[i];
}
let average = sum / numbers.length;
return average;
}
/* From here down, you are not expected to
function fizzBuzz(countTo) {
let arr = [];
for (i=1;i<=countTo;i++) {
if (i%3==0 && i%5==0){
arr[i] = 'fizzbuzz';
}
else if (i%3==0) {
arr[i] = 'fizz';
}
else if (i%5==0) {
@willwalker753
willwalker753 / Error alert drill.txt
Last active February 20, 2020 23:33
Error alert drill
function main() {
try {
doAllTheThings();
}
catch(FatalException) {
console.log('Caught FatalException '+FatalException);
reportError(FatalException);
}
}