Ask Question
23 June, 18:35

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?

+2
Answers (1)
  1. 23 June, 18:40
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers