You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
342 B
JavaScript
20 lines
342 B
JavaScript
let counter = 0;
|
|
|
|
// Print "Hello World"
|
|
// Every second
|
|
const interval = setInterval(
|
|
() => {
|
|
console.log(counter)
|
|
console.log('Hello every second');
|
|
counter++;
|
|
|
|
// And stop after 5 times
|
|
if (counter === 5) {
|
|
// After 5 times. Print "Done" and let Node exit.
|
|
console.log("Done");
|
|
clearTimeout(interval);
|
|
}
|
|
},
|
|
1000
|
|
);
|