Skip to content

Instantly share code, notes, and snippets.

@di-ma-73
Last active June 25, 2020 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save di-ma-73/0e3819651b9bc4b545c21e3d0d9def75 to your computer and use it in GitHub Desktop.
Save di-ma-73/0e3819651b9bc4b545c21e3d0d9def75 to your computer and use it in GitHub Desktop.
/*
* 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