+ 1

Why javascript is not working in this calculator.

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

11th Dec 2022, 3:42 PM
SHŪBHÃM
SHŪBHÃM - avatar
5 Answers
+ 5
I noticed 3 issues: 1. Your html input field only allows numbers – we cannot enter "+" for example. Consider using type="text" instead of type="number" 2. In line 8 of your js there is a typo: It needs to be innerText instead of innertext. 3. When the js is executed, the html is not fully loaded yet, so it doesn't find the html element that you try to get in the js code. Consider putting all your js code inside of window.onload: window.onload = function() { // here your js }
11th Dec 2022, 4:18 PM
Lisa
Lisa - avatar
+ 4
Line 6 innertext should be innerText
11th Dec 2022, 4:16 PM
ODLNT
ODLNT - avatar
+ 2
I think you've declared a few things incorrectly. Why not use ids for each button and add event listeners for each?
11th Dec 2022, 4:10 PM
Ausgrindtube
Ausgrindtube - avatar
0
Bcz I have to do it differently and also to save time.
11th Dec 2022, 4:12 PM
SHŪBHÃM
SHŪBHÃM - avatar
0
Thanks Lisa for help now it's working.
11th Dec 2022, 5:18 PM
SHŪBHÃM
SHŪBHÃM - avatar