+ 2

What is wrong with thus Code? Im kinda New to Web dev

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

20th Sep 2018, 11:44 PM
Nidhal Baccouri
2 odpowiedzi
+ 2
You get dom element reference (throught getElementById) before dom is loaded because js tab code is inserted in <head> then your js is loaded before body
20th Sep 2018, 11:56 PM
KrOW
KrOW - avatar
+ 2
Hi! You can do this: function TrimorphicNumbers () { //we put this in the function var myBtn = document.querySelector('button'), myResult = document.querySelector('p'), myInput = document.querySelector('input'); var val = myInput.value.toString(), cube = Math.pow(val,3).toString(), temp=cube.substring(cube.length -val.length ); if(temp===val) { myResult.textContent="True"; } else { myResult.textContent="false"; } }
21st Sep 2018, 12:09 AM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar