+ 2
What is wrong with thus Code? Im kinda New to Web dev
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
+ 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";
}
}