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
/** | |
* At specified interval takes next x of xs and calls f(x) | |
* Returns abort function, which stops iteration | |
* @param xs - arguments array for f | |
* @param f - a function | |
* @param delay - delay between calls, ms | |
*/ | |
const intervalForEach = (xs, f, delay) => { | |
const gen = xs.entries() | |
const id = setInterval(() => { |
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
// Generates and logs a random number between 1 and 4, pushes it to an array, and logs it | |
var arr = []; | |
function randomNumber() { | |
var num = Math.floor((Math.random() * 4) + 1); | |
arr.push(num); | |
console.log(arr); | |
} |