Hi all. I’ve learned how to use an if
, else if
and else
statement, like this:
var aNumber = 5;
if (aNumber === 5) {
console.log(aNumber); // 5
}
But what if I use an if statement like this?
var aNumber = 5;
if (aNumber === 5) {
if (aNumber) {
console.log("This will print because both inner and outer if statement are true."); // This will be printed since the test is true.
}
} else {
console.log("This statement will not run since both inner and outer if statement are true, so that the else block will not run."); // This will not run.
}
Does this one is called nested if statements??
Please answer.
Thanks!
Pummarin