Ask Question
3 October, 16:20

We have an array of Rectangles called rectangleArray and a function updateRectangle (rect) that takes a single rectangle as a parameter and changes its color to a random color. How can we easily change the color of every rectangle inside rectangleArray?

+4
Answers (1)
  1. 3 October, 17:42
    0
    Following are the code

    for (var k = 0; k< rectangleArray. length; k++) / / iterting the loop

    {

    updateRectangle (rectangleArray[k]); / / update the rectangle color

    }

    Explanation:

    In the given answer we have iterate over the loop will iterated until the length of rectangle array size-1 In every value of k, we have called the update rectangle function which changes the color of the rectangle of a rectangle class
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “We have an array of Rectangles called rectangleArray and a function updateRectangle (rect) that takes a single rectangle as a parameter and ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers