Why is this solution not accepted?


#1

Hey, community!

I'm trying to understand what is it wrong with my code. It returns me an error, however gets the job done: the phrase is printed three times, with no repetition of the console.log code.

Thanks in advance,
Daniel

https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/1/1?curriculum_id=506324b3a7dffd00020bf661

error message: Oops, try again. Hey now--only one console.log() call!


var count = 0;
function loop() {
    while (count < 3) {
        console.log ("I'm looping!");
        count++;
    }
}

loop();


#2

Daniel,

Adjust it so it loops 3 times: count<4, rather than 3.

Otherwise, it looks fine.


#3

Hello, Orion! :slight_smile: Thank you for your response.
The thing is it does print three times. It actually works in every way, but, for some reason, the lesson wouldn't let me through with this code.

If I change it to <4, as you suggested, it would print 4 times: for 'count' being equal to 0, 1, 2 and 3.


#4

The code runs alright for me... I don't think there's any error at all.


#5

i agree with @envyennui, i think you hit a glitch. Try refreshing page/different browser


#6

Oops... I can't read. :wink:


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.