[Blackjack game] Cannot read property 'append' of null in code and also webpage keeps on reloading.

hello, there are few issues with my code. i tried looking up the stack, it says the function is running before html and also i wanted to implement black jack cards to the corresponding values when the user clicks on hit. when doing so the webpage keeps on reloading. i tried moving the script file below the body in the html still same issue. Any help is appreciated. https://github.com/Avinash-Tallapaneni/Black-Jack https://scrimba.com/scrim/cG82vWCR
GitHub
GitHub - Avinash-Tallapaneni/Black-Jack
Contribute to Avinash-Tallapaneni/Black-Jack development by creating an account on GitHub.
Scrimba
Untitled Scrim
Learn to code with interactive screencasts. Our courses and tutorials will teach you React, Vue, Angular, JavaScript, HTML, CSS, and more. Scrimba is the fun and easy way to learn web development.
4 Replies
MarkBoots
MarkBoots2y ago
because you use function expressions (const someName = () => {...}) you need to be sure these are declared before they are called. move these lines to the end of the file (you don't need the onload event)
MarkBoots
MarkBoots2y ago
other option is to use the normal function format (function someName (){...}), then the order doesnt matter After this there are still some other issues left (but try to figure them out yourself first)
Avinash
Avinash2y ago
hey sorry that was previous version in scrimba. the posted scrimba link shows the updated code. @MarkBoots
MarkBoots
MarkBoots2y ago
that doesnt change my answer. also you are trying to get the stay and hit element by id, while they have a classname
Want results from more Discord servers?
Add your server
More Posts