turn ('direction') where 'direction' = 'left' or 'right'
Window to edit your JavaScript code
Test your script
Résult of your code
Évolution of the walk of the bear...
The bear is looking for honey
The goal is to put two functions and their arguments into practice.
The bear finds itself at the bottom left of a maze that is scattered with obstacles. He is hungry, so you must guide him to the honey feast at the bottom right side of the maze, but make him expend as little energy as possible in doing so.
There are two functions you can use to do this :
1. forward (x); where x is an « argument », in this case, a positive integer equal to the number of squares the bear must move ahead;
2. turn ('direction'); lets you turn the bear a quarter turn (90°), either to his left or his right.
To make your task easier, you can « copy/paste » from the list of functions found on the top of this exercise.