On Codecombat level Backwoods Forest - Leave it to the Cleaver I put in my code but it shows a red warning sign and a message saying “Expected an identifier and instead saw ‘.’.” Please send any suggestions or help on this, as it has happened many times before, but I still went through the level.
Also, I think I have the right code for this level, but it does not work for me. Here is my code:
// This shows how to define a function called cleaveWhenClose
// The function defines a parameter called target
function cleaveWhenClose(target) {
if(hero.distanceTo(target) < 5) {
// Put your attack code here
// If cleave is ready, then cleave target
if hero.isReady("cleave");
hero.cleave(target);
// else, just attack target!
else {
hero.attack(target);
}
}
}
// This code is not part of the function.
while(true) {
var enemy = hero.findNearestEnemy();
if(enemy) {
// Note that inside cleaveWhenClose, we refer to the enemy as target.
cleaveWhenClose(enemy);
}
}
Please send any help or suggestions on this too, as I cannot figure this out.