fixed error handling

This commit is contained in:
2025-08-14 12:03:30 -04:00
parent 48ade4eef6
commit 419c6e0c99

View File

@@ -8,12 +8,9 @@ console.log(promptInputHigh);
const promptInt = parseInt(promptInput);
const promptIntHigh = parseInt(promptInputHigh);
if ( Number.isInteger(promptInt) || Number.isInteger(promptIntHigh) ) {
if ( Number.isInteger(promptInt) && Number.isInteger(promptIntHigh) ) {
console.log(promptInt);
console.log(promptIntHigh);
} else {
console.log(`Error: One or more of the provided inputs is not a number.`);
}
// Use Math.random() and the user's number to generate a random number
@@ -22,3 +19,6 @@ const resultNumber = Math.floor(Math.random() * promptIntHigh) + promptInt;
// Create a message displaying the random number
console.log(`A random number between ${promptInt} and ${promptIntHigh} is ${resultNumber}.`);
} else {
console.log(`Error: One or more of the provided inputs is not a number.`);
}