Why do we use else if (chained if statements) in this case where we have the return statement to be executed when the condition is satisfied? As far as I know, the return statement stops the function from executing, so we’d essentially get the same value if we chained the statements or didn’t.
Your code so far:
function testElseIf(val) {
if (val > 10) {
return "Greater than 10";
}
if (val < 5) {
return "Smaller than 5";
}
return "Between 5 and 10";
}
testElseIf(7);
Challenge: Introducing Else If Statements
Link to the challenge: