Skip to content

Commit

Permalink
Solved timer challenge jscomplete#4. A little convoluted
Browse files Browse the repository at this point in the history
  • Loading branch information
bpirrocco committed May 13, 2023
1 parent d3d55f4 commit 179adf3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions 1-getting-started/2-timers/9-more-challenges-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const greeting = delay => {
const newDelay = Math.ceil(delay / 5);
const intervalDelay = newDelay * 100;
const intervalId = setInterval(() => {
console.log(`Hello world. ${intervalDelay}`);
delay += 1;
if (delay > (newDelay * 5)) {
clearInterval(intervalId);
greeting(delay);
}
}, intervalDelay);
}

greeting(1);
2 changes: 1 addition & 1 deletion 1-getting-started/2-timers/9-more-challenges.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Challenge 1:
Challenge 1:

Print "Hello World" forever. Starting with a delay of 1 second
but then incrementing the delay by 1 second each time.
Expand Down

0 comments on commit 179adf3

Please sign in to comment.