I need to execute a if/else conditional inside a JS 'for' loop. Specifically, this is what I'm told to do:
Here is my code
var numSheep = 4;
var monthsToPrint = 12;
for (var monthNumber = 1; monthNumber <= monthsToPrint; monthNumber++) {
if (numSheep < 10000) {
numSheep *= 4;
console.log("There will be " + numSheep + " sheep after " + monthNumber + " month(s)!");
} else {
numSheep *= 4;
var number = numSheep / 2;
var newNum = numSheep - number;
console.log("Removing " + number + " sheep from the population. Phew!");
console.log("There will be " + newNum + " sheep after " + monthNumber + " month(s)!");
}
}
Everytime I submit this code I get this error from codeschool, "You're calling console.log the correct number of times, but not logging the correct messages. Are you diving the numSheep by 2 whenever there are more than 10000."
P.S: It's challenge no. 5 of JavaScript Road Trip Part 2 on codeschool. If you need to log into codeschool and see for yourself, this link should give a 48 hour access: http://go.codeschool.com/eO1V6A