Want to receive Question of the Day updates? Subscribe Here
JavaScript Question of the Day
April 4, 2025
IncorrectCorrectNo Answer was selectedInvalid Answer
Consider the following program:
let rect;let red ="red";let blue ="blue";functionmain(){drawRect(100,100,getWidth()/2,getHeight()/2, blue);setTimer(animation,100);}functiondrawRect(width, height, x, y, color){
rect =newRectangle(width, height);
rect.setPosition(x - width /2, y);
rect.setColor(color);add(rect);return rect;}functionanimation(){
rect.setColor(Randomizer.nextColor());
rect.move(0,5);if(rect.getY()+100>=getHeight()){makeRed();}if(rect.getColor()== red){stopAnimation();}}functionmakeRed(){
rect.setColor(red);}functionstopAnimation(){stopTimer(animation);}main();
JavaScript
What will the color of the rectangle be when the program is finished running?