Created
February 6, 2020 01:23
-
-
Save klinquist/1d2fe03080d7c188df391cd93c91d767 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
const getEntryEveryMinutes = 5; | |
const randomNumber = (min, max) => { | |
return Math.floor(Math.random() * (max - min) + min); | |
}; | |
const myArray = []; | |
setInterval(() => { | |
myArray.push(randomNumber(1,100)); | |
if (myArray.length == 13) myArray.shift(); | |
let total = 0; | |
for (let i = 0; i < myArray.length; i++){ | |
total = total + myArray[i]; | |
} | |
const avg = Math.round(total / myArray.length); | |
console.log(`Running average is ${avg}. Number of items in array ${myArray.length}`); | |
}, getEntryEveryMinutes*60*1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment