+ 1
Help me understand.Why does my code "Calculator" work in my browser and not here in the console
3 Answers
+ 7
Code for question: https://code.sololearn.com/W4x9U3p8e5dz/?ref=app
Pretty sure the line:
var box=document.getElementById("display");
is being executed before the page is loaded, therefore the element display is not found.
This can be fixed by declaring the global variable box as empty and setting it inside a body or window onload function.
Here is your code with the changes I mentioned
https://code.sololearn.com/WQ3jdxz50l8e/?ref=app
+ 4
https://code.sololearn.com/Wnq4BuoD8aGy/?ref=app
+ 1
Thanks!