export default function App() {
/**
* Challenge: Create a `Roll Dice` button that will re-roll
* all 10 dice
*
* Clicking the button should generate a new array of numbers
* and set the `dice` state to that new array (thus re-rendering
* the array to the page)
*/
const [dice, setDice] = React.useState(allNewDice())
function allNewDice() {
const newDice = []
for (let i = 0; i < 10; i++) {
newDice.push(Math.ceil(Math.random() * 6))
}
return newDice
}
const diceElements = dice.map(die => <Die value={die} />)
return (
<main>
<div className="dice-container">
{diceElements}
</div>
{/*New button here*/}
</main>
)
}
import React from "react"
import Die from "./Die"