Stuck on Level 7 loop da loop Java script


#1

So it says that i need my code to be under 6 statements ,but clearly it is can someone help it would be great. :grinning:

// The code in this loop will repeat forever.
while (true) {
// Move right
this.moveRight(1);
// Move up
this.moveUp(1);
// Move left
this.moveLeft(1);
// Move down
this.moveDown(1);}


#2

Use this.moveRight() instead. The 1 counts as a statement.

If you delete the 1s it will pass.

Also default code for JS Hour of Code uses:

while(True){
instead of
while(true){


#3

Fixed that, thanks! :slight_smile:


#4

I put the following prior to finding this thread and it is giving me the error, “ReferenceError: True is not defined.” can you tell me what I am doing wrong?

while(True){
this.moveRight();
this.moveUp();
this.moveLeft();
this.moveDown();

Everything below the while(True) is indented but does not appear to be showing in my question.


#5

use a lowercase t with true.


#6

Oh, wow. Maybe I misunderstood the previous replies but I thought the true had to be capitalized.
Thank you very much.


#7

It depends on your programming language. Boolean value names (true/false) are not capitalized in JavaScript, Lua, CoffeeScript and ClojureScript; they are capitalized in Python.


#8

Thank you so much for helping !!!