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 ();
}

Computer Science & Information Technology

You might also like to view...

You cannot bind a LINQ query’s result directly to a ListBox. You must first ________.

a) bind the result to a ListItem b) clear the ListBox c) convert the results to a List with method ToList d) cast the result to a ListBoxItem

Computer Science & Information Technology

Which of the following gives the number of elements in the array int r[ 10 ]?

a. sizeof r b. sizeof ( *r ) c. sizeof r / sizeof ( int ) d. sizeof ( *r ) / sizeof ( int )

Computer Science & Information Technology

A ________ is a designer-quality appearance that includes coordinating colors, matching fonts, and effects such as shadows

A) placeholder B) style C) template D) theme

Computer Science & Information Technology

A toolbar with common formatting commands is the ________

Fill in the blank(s) with correct word

Computer Science & Information Technology