0
How do I replace the "NaN" value with "error" or something like it? (For ecample when ypu press valculate without parameter)
2 Respostas
+ 2
if (isNaN(calculate)) {calculate = "Err"}
document.querySelector("#result").innerHTML = calculate;
0
You should first change the input type from text to number:
type="number"
And then just add an error handling in your code, you can check with JS, if either the input or your result is a number and print something different if not.