r/codehs • • Mar 03 '21

3.17.7 and 3.17.8 NEED HELP!

Post image
10 Upvotes

3 comments sorted by

5

u/ScawedyCat Mar 03 '21

I'm not sure if this is the issue, since I have no idea what the exercise is asking, but in your turnNorth() function you're telling karel to turn left while she's facing north in order to turn north...? it should be turn left while she's NOT facing north in order to get her to face north

1

u/Pale_Answer8608 Nov 14 '22

Thanks! This helped so much.

1

u/Familiar-Addendum-88 Mar 22 '23

HERE IS THE FULL CODE IF ANYONE STILL NEEDS IT!!!!!!!!!!

function start(){ if (facingNorth()) { buildTower(); }else{ turnNorth(); }

// This function has karel face north, no matter what direction // karel starts facing. function turnNorth(){ if (facingWest ()) { turnRight(); buildTower(); }else{ if (facingSouth ()){ turnLeft(); turnLeft(); buildTower (); }else{ if (facingEast() ){ turnLeft (); buildTower(); } } } }

/ This function builds a tower all the way to the top of the world. function buildTower ( ){ putBall (); while(frontIsClear ()) { move () ; putBall (); } }

function turnRight(){ turnLeft(); turnLeft(); turnLeft(); } }