General Question

hullcrush's avatar

How do I simply repeat a line of code 4x in Javascript?

Asked by hullcrush (14points) January 11th, 2018

I know it is something like a while true loop – the correct solution for the game is:

forward();
forward();
forward();
forward();

I am assuming that’s a command. What is an easy way to do this? Thanks!

Observing members: 0 Composing members: 0

2 Answers

funkdaddy's avatar

something like a for loop is pretty simple, and gives you a handy counter if needed.

for(var i = 0; i < 4; i++) {
forward();
}

Response moderated (Spam)

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther