Last active
June 25, 2020 17:50
-
-
Save di-ma-73/0e3819651b9bc4b545c21e3d0d9def75 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* A stupid solution for task from https://habr.com/ru/post/328864/ | |
* Write a program that prints into console the numbers from 1 to 100. But for multiples of three print "Miss" instead of the number and for the multiples of five print "Kiss". For numbers which are multiples of both three and five print "MissKiss". Each print must be asynchronous call console.log function with a 50ms delay. | |
* Environment: Node.js | |
*/ | |
let print1 = (m, isActive = true, isRecursion = false) => { | |
if (!isActive) | |
return | |
else if (!isRecursion) | |
setTimeout(() => { console.log(m); isActive = false }, 1000) | |
else return print1(m, isActive, true) | |
} | |
for (let i = 0; i !== 101; ++i) { | |
if (i % 3 === 0) print1('Miss') | |
if (i % 5 === 0) print1('Kiss') | |
if (i % 3 !== 0 && i % 5 !== 0) print1(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment