This is the code that I tried.
function main() {
while (frontIsClear()) {
//this tells karel to go and put beepers
putBeeper();
move();
}
if (frontIsBlocked()) {
//this tells karel to change the direction if there's a wall
if (facingEast()) {
turnLeft();
putBeeper();
if (frontIsClear()) {
//and this brings karel to the upper street
move();
turnLeft();
} else {
turnRight();
}
}
if (facingWest()) {
turnRight();
putBeeper();
if (frontIsClear()) {
move();
turnRight();
} else {
turnRight();
}
}
}
}
When I run the code it gives me an error. It says ReferenceError: virtualDirection is not defined. Pls help. Thanks.