It needs to be edited to also allow: numSheep = 4 * numSheep instead of numSheep = numSheep * 4I actually spent 10 minutes trying to figure out what was wrong.

moderator: Yikes! Sorry about that. Definitely frustrating. This course is fairly officially planned for a migration to a newer platform, where it's very likely odd issues like this are better handled.

var numSheep = 4;var monthNumber = 1;var monthsToPrint = 12;while (monthNumber <= monthsToPrint) { numSheep *= 4; console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!"); monthNumber++;}I banged my head for atleast two hours to figure out what went wrong with the code,though I am getting correct output. It just one BLOODY NO SPACE AFTER EXCLAMATION MARK. It gave me so much grief but also taught me how important the SPACES were. Thank you CODE SCHOOL.

I'm confused how numSheep goes from 16 in month1 to 64 in month 2. I get that monthNumber is incremented from 1 to 2 due to monthNumber++, but how did numSheep get to 64? Did the last value of numSheep, numSheep*=4 get carried over in the second loop?

Since " ! " in JavaScript is used as a negation, using two " !! " negates the negation. It is like shortcut for Boolean(). The aforementioned returns the Boolean value. Once monthNumber-- gets to zero, since zero is considered a falsy value, it will breaks the loop.

** The line monthNumber = monthNumber++; actually doesn't increment monthNumber as a final result, but only does so briefly due to monthNumber++. It then takes the original version of monthNumber, the non-incremented version, and assigns it over top of monthNumber.

Likely.

What is for sure is it doesn't work, at likely doesn't work in any environment.

In many languages, even C in which I believe JavaScript was, at least originally, written, you have to be careful with assignments that have the same variable on both sides of = and use post/pre increment/decrement operators. The results are often undefined, depending on the compiler.

My code above should be correct? The output looked like the answer. Can someone explain why I had to place numSheep*=4; above the console.log inside the while statement instead of below? Thanks!

My output:
There will be 16sheep after 1 month(s)!
There will be 64sheep after 2 month(s)!
There will be 256sheep after 3 month(s)!
There will be 1024sheep after 4 month(s)!
There will be 4096sheep after 5 month(s)!
There will be 16384sheep after 6 month(s)!
There will be 65536sheep after 7 month(s)!
There will be 262144sheep after 8 month(s)!
There will be 1048576sheep after 9 month(s)!
There will be 4194304sheep after 10 month(s)!
There will be 16777216sheep after 11 month(s)!
There will be 67108864sheep after 12 month(s)!