Created
July 7, 2020 23:05
-
-
Save pbzona/3357d4b6d761046390824687b54b525e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Change the value of `array` to see how it behaves with defferent sets | |
const array = [0, 1, 2, 3, 4, 5]; | |
// Increase the value of `numberOfLoops` to see more examples | |
const numberOfLoops = 20 | |
console.log("MODULO EXAMPLES"); | |
for (let i = 0; i < numberOfLoops; i++) { | |
let res = array[(i % array.length)]; | |
console.log(`${i} % ${array.length} = ${res}`); | |
}; | |
// Copy this into a file named mod.js (or whatever you want) | |
// Run: node mod.js | |
// Experiment with different values in the array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment