Skip to content

Instantly share code, notes, and snippets.

@pbzona
Created July 7, 2020 23:05
Show Gist options
  • Save pbzona/3357d4b6d761046390824687b54b525e to your computer and use it in GitHub Desktop.
Save pbzona/3357d4b6d761046390824687b54b525e to your computer and use it in GitHub Desktop.
// 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