NEW
Font size
WorksheetsJRDL - JS Arrays and Objects
Total questions: 12
Worksheet time: 6mins
TRUE OR FALSE:
You can store any data type in arrays.
True
False
Which of the following is the correct syntax for creating an array?
{ "cat", "dog, "mouse", 123, true }
[ cat, dog, mouse, 123 }
[ "cat"; "dog"; "mouse"; 123, true]
[ "cat", "dog", "mouse", 123, true]
With the given array, how do I access "snickers"?
var candy = ["m & m's", "100 grand", "snickers"]
candy[1]
candy[3]
candy[2]
candy[0]
What are the two ways you can access objects?
Dot notation and bracket notation
Curl notation and dot notation
Square brackets and parentheses
Dot notation and parentheses
What is the correct syntax for adding a property to the object provided below?
var cat = {};
cat[name] = 'felix';
cat[name] : 'felix';
cat.name : 'felix';
cat.name = 'felix';
TRUE OR FALSE: You can use .length on an array to get the total count of items in the array.
True
False
What is the correct syntax for accessing an object using bracket notation?
Example object:
var object = {
name: 'Spot';
}
object["name"];
object{name};
object("name");
object[name];
What would the following code log on the console:
var pizza = {
topping1: "extra cheese",
topping2: "pepperoni",
topping3: "mushrooms",
size: "large"
}
console.log(pizza.topping2);
"mushrooms"
"large"
"pepperoni"
undefined
What will the following code log on the console:
var myArray = ["hello", "world", "maryknoll"];
console.log(myArray[3]);
"hello"
"world"
"maryknoll"
none of the above
TRUE OR FALSE: Objects can be accessed with value's index.
True
False
TRUE OR FALSE: Arrays can be accessed with dot AND bracket notation
True
False
What does console.log() do?
Saves your code to the computer memory.
Nothing. That's not a thing.
Logs your code on the console in the web browser.
Logs your code to a word document.
