mirror of
https://github.com/MrEidam/PetPet.git
synced 2026-04-17 15:43:31 +00:00
17 lines
505 B
JavaScript
17 lines
505 B
JavaScript
const dice = document.querySelector('#dice'); //img
|
|
let answear = document.querySelector('#answear'); //text ans
|
|
let number = document.querySelector('#num'); //num selec
|
|
|
|
function roll(){
|
|
let newDice = Math.floor(Math.random()*6);
|
|
|
|
console.log(newDice);
|
|
|
|
dice.src = `./${newDice+1}.png`;
|
|
|
|
if(number.value == newDice+1){
|
|
answear.innerHTML = `<p class='won'>Correct! +10 coins</p>`;
|
|
}else{
|
|
answear.innerHTML = `<p class='lose'>Wrong!</p>`
|
|
}
|
|
} |