This does not seem to be working I am not sure how to get this while loop to work correctly any help would be appreciated.
function getProductCode() {
productCode = parseInt(prompt("Enter Product Code: "));
while (productCode < 1 || > 9999)
{
document.writeln("Error! the product Code must be between 1 - 9999");
parseInt(prompt("Enter Product Code: "));
}
return productCode
}
getProductCode()
You’re missing an operand (
productCode) at the left side:And:
parseInt. When unspecified,010becomes 8 (octal literal).varto declare local variables.isNaN. When an invalid number is supplied (NaN), your loop should not stop.document.writelnto the dialog.productCode. Otherwise, you won’t get far…Final code which takes care of the first 5 bullet points:
I have not implemented the treshold, it’s up to you to do that.