Magic Eight Ball Conditionals and Loops

https://codehs.com/sandbox/malaysia123/8-ball

Hi, I’m creating a Magic Eight Ball and I want to include an if/else statement and a for loop, but I don’t know how I could add that in my code. Any help would be appreciated, thanks.

function start(){
eightBall();
questionare();
}

var randomItem = Randomizer.nextInt(0,1);
var arr = [“No”,“yes”];

function eightBall(){
var ball = new Circle(100);
var centerX = getWidth() / 2;
var centerY = getHeight() / 2;
ball.setPosition(centerX, centerY);
ball.setColor(Randomizer.nextColor());
add(ball);

var number = new Text("8");
number.setFont("50pt Arial");
number.setColor(Color.white);
number.setPosition(centerX - number.getWidth()/2, centerY + number.getHeight()/3);
add(number);

}

function questionare(){
var question = readLine(“Ask a question:”);
println("Answer: " + arr[randomItem]);
}

Hi,

Documentation is always one of the safest bets to check when in doubt:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html