[x] Check if the <select> has the default option (with no value).
[x] You are writing many times "trackEl.innerHTML = 'something';", what about making a function that accepts a string as param and paints it into 'trackEl'?
[x] Use ev.preventDefault() to prevent page reload.
Hi, i have made the changes you asked of me. Please, only if you have the time to review it , maybe you can give me some feedback on them. Thank you : )
Really cool job @ruadaslucia !!!
Here you have some tips to improve the exercise:
JavaScript: basic and logic
getRandomNumber()
function when the user clicks on "Jugar" button.getRandomNumber()
function outside the event callback, you will be creating a new random number when the page loads. That makes the game really simple and the hints will have the same result. Let's generate the random number when the user clicks on "Jugar" button and starts the round: https://github.com/Adalab/modulo-2-evaluacion-intermedia-ruadaslucia/blob/fcbb99a9dc61bd281c0755660f832b3f65a3f8a0/js/main.js#L17else
statement.leftover
stores an HTML element, you cannot do a math operation on an HTML element. This is the reason that on the page you get the money inNaN
: https://github.com/Adalab/modulo-2-evaluacion-intermedia-ruadaslucia/blob/fcbb99a9dc61bd281c0755660f832b3f65a3f8a0/js/main.js#L53JavaScript: advanced
<select>
has the default option (with no value)."trackEl.innerHTML = 'something';"
, what about making a function that accepts a string as param and paints it into'trackEl'
?ev.preventDefault()
to prevent page reload.HTML
CSS
Further challenges
Then you can improve the game as you please, here you have some ideas:
Call to action
Let me know if you have any doubts ;)
Go for it!!