The original code is written in Python, but it looks like you might be writing in JavaScript. The two languages use different syntax, a type of format with rules. You need to follow the correct syntax for the language you are writing in.
Python:
if pos.x == 34:
JavaScript
if (pos.x == 34) {
If you need specific help, post your code and someone can walk you through it. Below is a link that will help you post your code properly so we can help.
Not sure if the classroom version allows you to switch. The non-classroom lets you pick which language you want to work with when selecting the hero. Go to the Game Menu at the top and change hero. At the bottom, I have the option to change language.
If you can’t switch to Python, go ahead and click the Restart at the top right corner to get you back to the base code for JavaScript. We can go from there. You can use the same concept that is shown in the Python code, but you need to translate it into JavaScript.
This is what I currently have for right now… took me like… 5 hours but, I think I’m on the right track.
// In this level the evilstone is bad! Avoid them, walking the other direction.
while (true)
var evilstone = hero.findNearestItem();
if (evilstone)
var pos = evilstone.pos;
if (pos.x == 34) (pos.y == 22);
hero.moveXY(46, 22);
if (evilstone) {
var pos = evilstone.pos;
if (gem.pos.x == 46) (pos.y == 22);
hero.moveXY(34, 22) ;
}
else {
hero.moveXY(40, 22);
}
If not, I’ll restart it but I want you to get an expert look at it before I make any changes.
May 4th 2019: Ok, i’ll make those revisions. If I’ve questions, i’ll ask you. (PS: since i’ve reached my limit, i’m gonna be communicating through here).
May 4th 2019: I did those revisions but it’s saying there is an error
You are getting there. A few details to work out. You are missing several of the brackets {} with the if statements. Another thing, the pos.y == 22 check is not needed at all.
The second check can be simplified. You are still checking for the evilstone again, when you don’t need to in this one. Just check the pos.x position like the first one, but the right side.
if (evilstone) { // not needed
var pos = evilstone.pos; // not needed
if (gem.pos.x == 46) (pos.y == 22); // only need if (pos.x == 46){
hero.moveXY(34, 22) ;
}