Making Decisions
Combining a sensor with an if statement lets your robot react differently depending on what it finds: if (robot.senseWall()) { /* do one thing */ } else { /* do another */ }.
Your turn
Open the Robotics Lab and solve "Think Twice" — sense the wall, then choose which way to turn.
- Used an if/else based on robot.senseWall()
- Robot reaches the goal
Ask JARVIS for a hint