I've done it to be honest, but I feel like I'm writing extra code. I want a shortcut.
The code is:
let num1 = +prompt("enter a number");
let num2 = +prompt("enter a number");
if(isNaN(num1) || isNaN(num2) || num1 == num2) {
alert("Error!")
} else{
let smallnum = 0, bignum = 0;
if (num1 > num2){
smallnum = num2;
bignum= num1;
} else{
smallnum = num1;
bignum = num2;
}
i = smallnum + 1;
while(i < bignum){
if (i % 2 == 1){
i++;
console.log(i);
} else {
console.log(i);
}
i += 2;
}
}
Please tell me whether I've written well or not.