+ 4

Rock,paper,scissors buttons are not working as they are supposed to be. Would you mind helping me with this?(solved)

https://code.sololearn.com/W3MF6bNcJ6g2/?ref=app

26th Sep 2022, 4:54 PM
Hemasri Kottapalli
Hemasri Kottapalli - avatar
6 Answers
+ 7
Here, Add your js code in between : window.onload = () => { // here };
26th Sep 2022, 5:10 PM
Jayakrishna 🇼🇳
+ 7
Reason why you need to wrap your code inside window.onload is because js we type in js tab is same as we js inside head tag. That js code is rendered before html elements are created and we can't access them, so solution is using window.onload to run js code after html elements are loaded, or moving your js at end of body tag For code typed in js tab, if you plan to work with DOM (selecting html elements) always wrap it inside window.onload
26th Sep 2022, 9:48 PM
PanicS
PanicS - avatar
+ 3
Jayakrishna🇼🇳 Thank you so much♡
26th Sep 2022, 5:19 PM
Hemasri Kottapalli
Hemasri Kottapalli - avatar
+ 2
You're welcome..
26th Sep 2022, 8:27 PM
Jayakrishna 🇼🇳
+ 1
Randy post your code so we can see
28th Sep 2022, 8:18 AM
PanicS
PanicS - avatar
+ 1
Java script line 21 to 29 u are again and again re initialising computer choice so final reinitialization scissors will remain same and won't change .... change if condition to get different outputs for different input from Math.random
28th Sep 2022, 10:20 AM
Varun Kumar
Varun Kumar - avatar