wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JRDL - JS Arrays and Objects

Total questions: 12

Worksheet time: 6mins

Name
Class
Date
1.

TRUE OR FALSE:


You can store any data type in arrays.

a)

True

b)

False

2.

Which of the following is the correct syntax for creating an array?

a)

{ "cat", "dog, "mouse", 123, true }

b)

[ cat, dog, mouse, 123 }

c)

[ "cat"; "dog"; "mouse"; 123, true]

d)

[ "cat", "dog", "mouse", 123, true]

3.

With the given array, how do I access "snickers"?


var candy = ["m & m's", "100 grand", "snickers"]

a)

candy[1]

b)

candy[3]

c)

candy[2]

d)

candy[0]

4.

What are the two ways you can access objects?

a)

Dot notation and bracket notation

b)

Curl notation and dot notation

c)

Square brackets and parentheses

d)

Dot notation and parentheses

5.

What is the correct syntax for adding a property to the object provided below?


var cat = {};

a)

cat[name] = 'felix';

b)

cat[name] : 'felix';

c)

cat.name : 'felix';

d)

cat.name = 'felix';

6.

TRUE OR FALSE: You can use .length on an array to get the total count of items in the array.

a)

True

b)

False

7.

What is the correct syntax for accessing an object using bracket notation?


Example object:


var object = {

name: 'Spot';

}

a)

object["name"];

b)

object{name};

c)

object("name");

d)

object[name];

8.

What would the following code log on the console:


var pizza = {

topping1: "extra cheese",

topping2: "pepperoni",

topping3: "mushrooms",

size: "large"

}

console.log(pizza.topping2);

a)

"mushrooms"

b)

"large"

c)

"pepperoni"

d)

undefined

9.

What will the following code log on the console:


var myArray = ["hello", "world", "maryknoll"];

console.log(myArray[3]);

a)

"hello"

b)

"world"

c)

"maryknoll"

d)

none of the above

10.

TRUE OR FALSE: Objects can be accessed with value's index.

a)

True

b)

False

11.

TRUE OR FALSE: Arrays can be accessed with dot AND bracket notation

a)

True

b)

False

12.

What does console.log() do?

a)

Saves your code to the computer memory.

b)

Nothing. That's not a thing.

c)

Logs your code on the console in the web browser.

d)

Logs your code to a word document.