Move forward, turn right, move down to the ball, pick it up, turn around, move back up, and turn right to face the original direction. javascript
function main() buildTower(); moveToNextTower(); buildTower(); codehs all answers karel top
| Command | What it does | | :--- | :--- | | | | | move(); | Moves Karel one square forward. | | turnLeft(); | Turns Karel 90 degrees to the left. | | putBall(); | Places a tennis ball on Karel's current square. | | takeBall(); | Removes a tennis ball from Karel's current square. | | Conditional Checks | | | frontIsClear(); | Returns true if the square in front of Karel is empty. | | frontIsBlocked(); | Returns true if the square in front of Karel is a wall. | | ballsPresent(); | Returns true if there is at least one tennis ball on Karel's current square. | | noBallsPresent(); | Returns true if there are no tennis balls on Karel's current square. | | facingNorth(); | Returns true if Karel is facing North. | | facingSouth(); | Returns true if Karel is facing South. | | facingEast(); | Returns true if Karel is facing East. | | facingWest(); | Returns true if Karel is facing West. | | notFacingNorth(); | Returns true if Karel is not facing North. | | leftIsClear(); | Returns true if the square to Karel's left is empty. | | rightIsClear(); | Returns true if the square to Karel's right is empty. | Move forward, turn right, move down to the
Before diving into specific levels, remember the four basic commands Karel knows out of the box: – Moves Karel forward one space. turnLeft(); – Rotates Karel 90 degrees to the left. putBall(); – Drops one ball on the current tile. takeBall(); – Picks up one ball from the current tile. Solving Top Karel Challenges 1.1.4: Your First Karel Program | | putBall(); | Places a tennis ball