I cannot figure out why it turns back to default after the code is done. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

I cannot figure out why it turns back to default after the code is done.

Black background white text, turns back white and black text. Run it yourself. https://code.sololearn.com/WH2CXGg43Js3/?ref=app

17th Oct 2019, 12:07 AM
Zackery Spry
2 Answers
+ 6
The reason why everything is getting reset is because the document.write function will automatically clear your entire screen when using it. What I would suggest doing instead is pushing the text into an element rather than just using that function (one of the ways you could do that is by replacing document.write(... to document.body.innerHTML = num+' Doubled is: '+a+''; )
17th Oct 2019, 12:43 AM
Faisal
Faisal - avatar
- 1
Thank you
21st Oct 2019, 7:25 PM
Zackery Spry