I have made my function that takes user input and outputs it as true if it is the same number and false if it isn't. Now my application always outputs it as false. Sorry if this is bad code, I am a noob.
I have tried to replace "== NaN" with "< 0" with no success.
function compare(a, b) {
if (a == b) {
var valid = true;
} else {
var valid = false;
}
return valid;
}
function test(first, second) {
if (!isNaN(first) && !isNaN(second)) {
alert(compare(first, second));
} else {
alert('TRY AGAIN');
}
}
var firstStr = prompt('Enter first Number:');
var first = new Number(firstStr);
var secondStr = prompt('Enter second Number:');
var second = new Number(secondStr);
test(first, second);
I have not got any error messages however I got it stuck always on false, if there is anything else bad with my code please let me know.