Skip to main content
added 2 characters in body
Source Link
toolic
  • 6.4k
  • 4
  • 20
  • 79

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;
    }
}

and pleasePlease tell me whether I've written well or not.

I've done it to be honest but I feel like 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;
    }
}

and please tell me whether I've written well or not.

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.

added 2 characters in body
Source Link

I've done it to be honest but I feel like writing extra code. I want a shortcut

The code is:

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;
    }
}
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;
    }
}

and please tell me whether I've written well or not.

I've done it to be honest but I feel like writing extra code. I want a shortcut

The code is:

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;
    }
}

and please tell me whether I've written well or not.

I've done it to be honest but I feel like 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;
    }
}

and please tell me whether I've written well or not.

Source Link

Showing the even numbers between two numbers which the user has entered

I've done it to be honest but I feel like writing extra code. I want a shortcut

The code is:

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;
    }
}

and please tell me whether I've written well or not.