Question on if else


#1

I was playing around with arrays and attempted to print all the array items using various loops. I succeed when I used for, while, do while,
However, i was unable to print using if else loop.
Please check the below code and let me know if I made a mistake in writing the code or if using the if else loop the desire output is not possible.

var list = [true, "JavaScript", 1, "one", "60", "Developer"];
var i = 0;
if (i < list.length) {
    console.log (list[i]);
    i++;
    } else {
        console.log ("Completed printing all the array items");
        }

Expected output:

true
JavaScript
1
one
60
Developer

actual output:

true
0

#2

There is no such thing as an 'if-else loop'. If/else statements are conditional logic statements, not loops.


#3

Question is not about English grammar.... question is can we achieve the desired output using if else


#4

@sureshdev
Just to clarify:

THIS:

Is not a thing.

You cannot do this with an if-else loop, as it doesn't exist.


#5

ok... thanks for your help !