I Hate CBT's

View Original

5.9.5 Extend Vote For Me

Question: Why do we use while loops in JavaScript?

Answer: To repeat some code while a condition is true

Question: Which general while loop definition is written correctly?

Answer: D

Question: 5.1.3: Move to Wall

Answer: function start(){

while(frontIsClear()){

move();

}

}

Question: 5.1.4: Follow The Yellow Ball Road

Answer: // Follow the yellow ball road!

// Karel moves until it’s not on a tennis ball.

function start() {

while(ballsPresent()){

move();

}

}

Question: 5.1.5: Lay Row of Tennis Balls

Answer: /* Write a program to lay a row of tennis balls

* across first street. Make sure to test your

/

function start(){

while(noBallsPresent()){

putBall();

if (frontIsClear()){

move();

}

}

}