fixed error handling
This commit is contained in:
@@ -8,12 +8,9 @@ console.log(promptInputHigh);
|
|||||||
const promptInt = parseInt(promptInput);
|
const promptInt = parseInt(promptInput);
|
||||||
const promptIntHigh = parseInt(promptInputHigh);
|
const promptIntHigh = parseInt(promptInputHigh);
|
||||||
|
|
||||||
if ( Number.isInteger(promptInt) || Number.isInteger(promptIntHigh) ) {
|
if ( Number.isInteger(promptInt) && Number.isInteger(promptIntHigh) ) {
|
||||||
console.log(promptInt);
|
console.log(promptInt);
|
||||||
console.log(promptIntHigh);
|
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
|
// 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
|
// Create a message displaying the random number
|
||||||
|
|
||||||
console.log(`A random number between ${promptInt} and ${promptIntHigh} is ${resultNumber}.`);
|
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.`);
|
||||||
|
}
|
Reference in New Issue
Block a user