Six stars are created from a Star constructor function using six new statements as follows
var star1 = new Star();
var star2 = new Star();
var star3 = new Star();
var star4 = new Star();
var star5 = new Star();
var star6 = new Star();
(i) Create an array, say stars, and rewrite the code using a for-loop to store the Star objects in the array.
(ii) Suppose the Star object have two methods: spin() and fall(). Write a for-loop to invoke both methods on all six stars.
(i)
var stars = [];
for (var i=0; i < 6; i++)
{
stars.push(new star());
}
(ii)
for (var i=0; i < stars length; i++)
stars [i] spin ();
stars [i] fall ();
}
You might also like to view...
Which of the following is a true statement about PnP?
A. PnP automatically configures your network settings B. PnP only works on Windows Vista and later OSs C. PnP devices may still require configuration for optimal performance D. PnP always requires manual installation of the DVD drive
According to the Nyquist rule, the sampling rate of sound should be roughly
a. half of what humans can hear b. the same as what humans can hear c. twice what humans can hear d. three times what humans can hear