Put that loop in a function Problem


#1

image.

I am having a hard time trying to figure this out. Is the problem in my for loop or my function?


#2

Does it give you an error message? What exactly does happen when you run this?


#3

oops, try again: false. Something to that effect.


#4

I can’t really see anything wrong with the code myself, the only thing I notice is that the second line is not indented, though that probably wouldn’t make a difference. Is the program just trying to count up infinitely, or to a specific value?


#5

It is supposed to count up to 10.


#6

In that case, I think you’d need something to tell it that - for example

for (var i = 1; i <= 10; i++) {
    console.log(i) 
    }

This would set it to could up to 10 only I believe. I’m new to javascript myself, and not very good with it, so apologies if this doesn’t work haha


#7

I will try that. thanks, xander.coder. I figured out the loop needs to repeat up until 11


#8

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