Ask Question
7 January, 12:42

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?

+3
Answers (1)
  1. 7 January, 16:09
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers