When I console log both, both returns 4 for me. In this case the correct answer is The first answer for me. But the challenge accepts second answer as correct!? Can anybody explain why?
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
Learn Variables and Operators - Learn Variables and Operators Lesson I
Thanks for your reply. After your reply I figured out, what I did wrong.
// Test it
let counter = 1;
console.log(2 * ++counter); // Statement A
let counterOne = 1;
console.log(2 * counter++); // Statement B
To test it at once I changed the second variable name but forgot to update the same on console.log which would be “counterOne++” and that resulted both output as 4.
After correcting the blind spot it returns 4 and 2.