Skip to content

Instantly share code, notes, and snippets.

@ilonacodes
Created April 20, 2020 07:22
Show Gist options
  • Save ilonacodes/fafe9fa4368e9c82efa2f917af93f3c5 to your computer and use it in GitHub Desktop.
Save ilonacodes/fafe9fa4368e9c82efa2f917af93f3c5 to your computer and use it in GitHub Desktop.
index.js | VanillaJS Implementation
// index.js | VanillaJS Implementation
const dices = window.document.querySelectorAll('.dice');
const roll = () => {
dices.forEach(dice => {
const dots = Math.floor(Math.random() * 6) + 1;
dice.setAttribute("data-dots", dots);
})
};
// first initial roll for when the page loads
roll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment