Font size
WorksheetsArrays
Total questions: 20
Worksheet time: 20mins
Pick up the odd one
List
variable
array
positioning of values inside array is called as
position
index
number
values
Choose the incorrect format of creating an array
array_name2=[];
array-name=[];
2arrayname=[];
array@name=[];
array$name=[];
var names= ["batMan", "spiderMan", "hulk", "Avengers"];
value = names[1];
console.log(value);
batMan
spiderMan
hulk
Avengers
var names= ["bat man", "spider man", "hulk", "Avengers"];
value = names[4];
console.log(value)
Avengers
hulk
undefined
Pick the correct syntax to find the number of values inside an array
arrayname.values;
arrayname.length;
arrayname.length();
Code to get the last value in this array
var names= ["bat man", "spider man", "hulk", "Avengers"];
names[(names.length)-1];
names[3];
(names.length)-1
Ways of adding a new value to the end of the array
var names= ["bat man", "spider man", "hulk", "Avengers"];
names.push("aquaman")
names[names.length]="aquaman";
names.pop();
var names= ["bat man", "spider man", "hulk", "Avengers"];
console.log(typeof(names));
array
object
string
Choose all that is true about array
an array is a variable that is used to store different data types
stores multiple values in one box
an array is an ordered list of values
length of an array is dynamically sized and auto-growing
Every value is associated with numeric index starting with 1
Array index must be
string
numeric
both
Choose the best
ar names= ["bat man", "spider man", "hulk", "Avengers"];
status=Array.isArray(names)
console.log(status);
true
false
none
The marks obtained from each project submission based on the class number sorted can be best added/stored in?
variable
array
The total marks obtained from hats off, project submission, additional activities of projects and class attendance can be summed up and finally stored in ?
variable
array
Adds values to the array
push()
pop()
unshift()
shift()
Splice adds/removes item to/from any array.
var names= ["bat man", "spider man", "hulk", "Avengers"];
names.splice(2,0,"iron man")
console.log(names)
["bat man", "iron man", "spider man", "hulk", "Avengers"]
["bat man", "spider man", "iron man", "hulk", "Avengers"]
Splice adds/removes value from array
var names= ["bat man", "spider man", "hulk", "Avengers"];
names.splice(2,1)
console.log(names)
["bat man", "spider man", "Avengers"]
["bat man", "spider man"]
["bat man", "spider man", "hulk"]
Concept of inserting scores into the leaderboard and arranging scores from the highest to least can be done using?
arrayname.push() and arrayname.sort()
arrayname.push() and arrayname.reverse()
arrayname.pop() and arrayname.sort()
arrayname.pop() and arrayname.reverse()
collection of marks in an array is sorted descending, the highest mark can be fetched using the code
arrayname[0]
arrayname[arrayname.length-1]
arrayname.length
collection of marks in an array is sorted descending, the least score can be fetched using the code
arrayname[0]
arrayname[arrayname.length-1]
arrayname[arrayname.length]
