+ 1
Please someone help me with this JS code
So I was making a random number generator and I got stuck when the code is not working properly whenever I click on the button that doesn't erase the old output instead it's keep going on the old output so I need help in this code like whenever I click on the button the old output should be erased and new output will be written Please help I wish for you that you can never forget codes like I doš https://code.sololearn.com/W6M8byt35b1E/?ref=app
6 Answers
+ 3
there you go!
https://code.sololearn.com/WqR2AWeDc50e/?ref=app
+ 1
don't append text to the body, you should be targeting a tag that hold your text. it's possible by using an Id.
<p id="result"></p>
let resultElement = document.getElementById("result");
resultElement.innerText = number;
I hope this help :)
0
Can you please make a code please š
0
Just create a new text tag give it a id and simply replace body in you js by getElementById("Id")
0
And you are good to go
0
Also remove that += and simply use =