Files
CS343-Labs/Prep 2/codingjs-1.js
2025-09-10 14:42:57 -04:00

31 lines
996 B
JavaScript
Executable File

// s/o to https://the-winter.github.io/codingjs
// https://the-winter.github.io/codingjs/exercise.html?name=sleepIn&title=Warmup-1
function sleepIn(weekday, vacation) {
return !weekday || vacation
}
// https://the-winter.github.io/codingjs/exercise.html?name=monkeyTrouble&title=Warmup-1
function monkeyTrouble(aSmile, bSmile) {
return (aSmile && bSmile) || (!aSmile && !bSmile)
}
// https://the-winter.github.io/codingjs/exercise.html?name=sumDouble&title=Warmup-1
function sumDouble(a, b){
return a === b ? a * 4 : a + b
}
// https://the-winter.github.io/codingjs/exercise.html?name=frontBack&title=Warmup-1
function frontBack(str){
const chars = str.split("")
;[chars[0], chars[chars.length - 1]] = [chars[chars.length - 1], chars[0]];
return chars.join("")
}
// https://the-winter.github.io/codingjs/exercise.html?name=intMax&title=Warmup-1
function intMax(a, b, c){
// I'll assume Math.max(a, b, c) is cheating
return a > b && a > c ? a : b > c ? b : c
}