Last active
April 23, 2019 15:57
-
-
Save vitormalencar/71625e17125ffe017dc3d43b81aa2830 to your computer and use it in GitHub Desktop.
FoooBoo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rules | |
const isNotValidParams = (n, m) => n > m | |
const isNotInteger = n => !Number.isInteger(n) | |
const logger = number => { | |
let foo = number % 3 == 0 | |
let boo = number % 5 == 0 | |
console.log(foo ? (boo ? 'fooBoo' : 'Foo') : boo ? 'Boo' : number) | |
} | |
const print = (startNumber, endNumber) => { | |
if (isNotInteger(startNumber) || isNotInteger(endNumber)) { | |
return console.log('Invalid Input; Only Integers Allowed’.') | |
} | |
if (isNotValidParams(startNumber, endNumber)) { | |
return console.log('Start Parameter Cannot be Greater Than End Parameter’.') | |
} | |
for (let i = startNumber; i < endNumber; i++) { | |
// loggin every 1 sec | |
setTimeout(() => logger(i), 1000 * (i + 1)) | |
} | |
} | |
// initial call | |
setTimeout(() => print(0, 10), 2000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment