31 lines
996 B
JavaScript
31 lines
996 B
JavaScript
|
|
// 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
|
||
|
|
}
|