Review the following code:
if (counter <= 10) { if (counter >= 10) { console.log(1); } }
We can replace it using:
if (true) console.log(1);
if (false) console.log(1);
if (counter >= 10) console.log(1);
if (counter == 10) console.log(1);
Explanation & Hint:
The given code snippet can be simplified by removing the nested if statement, as it does not have any effect on the logic. In the simplified code, we directly check if the counter variable is equal to 10 using a single if statement. If the condition is met, meaning counter is exactly 10, then 1 will be logged to the console. |