I am struggling with the NEW and final part of this step, " Also, as we mentioned in step 1 that we are considering only positive numbers, we should add a third condition in IF statement to check whether the number is less than 0 (i.e negative numbers)"…
My code so far looks like this:
if (!numberInput.value || isNaN(parseInt(numberInput.value))) {
}
I have tried the following so far:
if (!numberInput.value || isNaN(parseInt(numberInput.value)) || numberInput.value < 0) {}
if (!numberInput.value || isNaN(parseInt(numberInput.value)) || (parseInt(numberInput.value < 0)) { }
Each time i get the same prompt back: You should wrap the value returned by parseInt()
in the isNaN()
function. And add a third condition which checks the value returned by parseInt()
to be less than 0.
Please let me know how I can pass this step and what I’m doing wrong!