Some improvements
Opened this issue · 0 comments
igarrido-adalab commented
Really cool job @Giselle-97 !!!
Here you have some tips to improve the exercise:
JavaScript: basic
- Execute
getRandomNumber
function when the user clicks on "Jugar" button. - Watch out for selector names used in
querySelector()
methods... they must exist in our HTML code!! (Look over this line https://github.com/Adalab/modulo-2-evaluacion-intermedia-Giselle-97/blob/30f5376f833554c59983e14e6e0376eb7598afbb/js/main.js#L5) - Watch out for constant names used to save DOM references... Do we want to use the DOM reference or that DOM element content (innerHTML/value)?
- Remove debugger and other unnecessary code
JavaScript: advanced
- You are writing many times
"trackEl.innerHTML = 'something';"
, what about making a function that accepts a string as param and paints it into'trackEl'
? - It's better to use a global variable to store the balance amount of the player, sum or subtract the bet and refresh the HTML using that variable.
Good practices
- Indent and avoid extra white spaces to improve readability and prevent bugs. Configurate code formatter in VS Code!!!
- Make multiple commits as you work.
- Try to improve your commits messages. "Add JS" is a bit poor. "Add random number logic" is more explanatory.
HTML
- Add form
- Don't leave attributes with empty value.
Further challenges
Then you can improve the game as you please, here you have some ideas:
- Check if the player has enough money to bet and if the bet is greater than 0 and lower than the current amount of the player.
- Add a reset button that cleans the select, balance of money and writes the initial feedback.
- Show the restart game button when the game is over and hide the play button.
- Complete the code needed for the restart game button.
- Validates if the balance of money is available is less than the money bet and displays a message
- Whatever you want!
Call to action
Let me know if you have any doubts ;)
Go for it!!
Do not close this issue until your teacher asks you to