// Use object literals to walk the safe path and collect the gems.
// You cannot use moveXY() on this level! Use move() to get around.
gems = this.findItems();
while (this.pos.x < 20) {
// move() takes objects with x and y properties, not just numbers.
this.move({'x': 20, 'y': 35});
}
while (this.pos.x < 25) {
// A gem's position is an object with x and y properties.
gem0 = gems[0];
this.move(gem0.pos);
}
while(this.pos.x < 30){
this.move({x:30,y:35});
}
while (this.pos.x < 35) {
this.move(gems[1]);
}
// While your x is less than 30,
// Use an object to move to 30, 35.
// While your x is less than 35,
// Move to the position of gems[1].
// Get to the last couple of gems yourself!

When I run this code my hero justs moves to the first X and stays there

I made that change and a handful of others but my code has an infinity loop could someone find the problem and tell me how to fix it

//Commented out to stop infinite loop.
// Use object literals to walk the safe path and collect the gems.
// You cannot use moveXY() on this level! Use move() to get around.
gems = this.findItems();
while (this.pos.x < 20) {
// move() takes objects with x and y properties, not just numbers.
this.move({x: 20, y: 35});
}
while (this.pos.x < 25) {
// A gem's position is an object with x and y properties.
gem0 = gems[0];
this.move(gem[0].pos);
}
while (this.pos.x < 30 ){
this.move({x:30,y:35});
}
while(this.pos.x < 35){
this.move(gems[1].pos);
}
// While your x is less than 30,
// Use an object to move to 30, 35.
// While your x is less than 35,
// Move to the position of gems[1].
// Get to the last couple of gems yourself!

# Use object literals to walk the safe path and collect the gems.
# You cannot use moveXY() on this level! Use move() to get around.
gems = self.findItems()
while self.pos.x < 20:
# move() takes objects with x and y properties, not just numbers.
self.move({'x': 20, 'y': 35})
while self.pos.x < 25:
# A gem's position is an object with x and y properties.
gem0 = gems[0]
self.move(gem0.pos)
# While your x is less than 30,
# Use an object to move to 30, 35.
while self.pos.x < 30:
self.move({'x':30, 'y': 35})
# While your x is less than 35,
# Move to the position of gems[1].
while self.pos.x < 35:
self.move({'x':35, 'y': 25})
# Get to the last couple of gems yourself!
while self.pos.x < 40:
self.move({'x':40, 'x': 25})
while self.pos.x < 45:
self.move({'x':45, 'y':35})
while self.pos.x < 50:
self.move({'x':50, 'y':45})

I tried this level but when I did it half way through he just walked away into the cliff?
This is my code.

// Use object literals to walk the safe path and collect the gems.
// You cannot use moveXY() on this level! Use move() to get around.
gems = hero.findItems();
while (hero.pos.x < 20) {
// move() takes objects with x and y properties, not just numbers.
hero.move({'x': 20, 'y': 35});
}
while (hero.pos.x < 25) {
// A gem's position is an object with x and y properties.
gem0 = gems[0];
hero.move(gem0.pos);
}
// While your x is less than 30,
// Use an object to move to 30, 35.
while (hero.pos.x < 30) {
hero.move({'x': 30, 'y': 35});
}
// While your x is less than 35,
// Move to the position of gems[1].
while (hero.pos.x < 35) {
gems1 = gems[1];
hero.move(gems1.pos);
}
// Get to the last couple of gems yourself!
while (hero.pos.x < 40) {
hero.move({'x': 40, 'y': 45});
}
while (hero.pos.x < 45) {
gems2 = gems[2];
hero.move(gems[2].pos);
}
while (hero.pos.x < 50) {
hero.move({'x': 50, 'y': 55});
}
while (hero.pos.x < 55) {
gems3 = gems[3];
hero.move(gems[3].pos);
}

You are incrementing the y coordinate in your move orders, the y is how much you walk in the UP (north) direction, you should keep y at 35 in all of them.

I don’t know if this is easier for anyone else, but for me personally I found the best way to complete it was using two Arithmetic Series. It reduced the whole program too minimal lines. If you have covered it in school give it a try.

# Use object literals to walk the safe path and collect the gems.
# You cannot use moveXY() on this level! Use move() to get around.
gems = hero.findItems()
while hero.pos.x < 20:
# move() takes objects with x and y properties, not just numbers.
hero.move({'x': 20, 'y': 35})
while hero.pos.x < 25:
# A gem's position is an object with x and y properties.
gem0 = gems[0]
hero.move(gem0.pos)
# While your x is less than 30,
# Use an object to move to 30, 35.
while hero.pos.x < 30:
hero.move({'x': 30, 'y': 35})
while hero.pos.x < 30:
gem1 = gems[1]
hero.move(gem1.pos)
# While your x is less than 35,
# Move to the position of gems[1].
while hero.pos.x < 35:
# move() takes objects with x and y properties, not just numbers.
hero.move({'x': 35, 'y': 35})
while hero.pos.x < 35:
# A gem's position is an object with x and y properties.
gem1 = gems[1]
hero.move(gem1.pos)
# Get to the last couple of gems yourself!
while hero.pos.x < 40:
# move() takes objects with x and y properties, not just numbers.
hero.move({'x': 40, 'y': 35})
while hero.pos.x < 45:
# A gem's position is an object with x and y properties.
gem3 = gems[3]
hero.move(gem3.pos)