JavaScript Test C
Question 1
What symbols are used to comment or cancel out code.
A. &&
B. !=
C. %%
D. //
A. &&
B. !=
C. %%
D. //
Question 2
Which of the following is the correct way of returning the length of this string?
A. "string",length
B. string,length
C. string.length
D. "string".length
A. "string",length
B. string,length
C. string.length
D. "string".length
Question 3
“I love making variables.” is an example of a …?
A. string
B. variable
C. Object
D. Boolean
A. string
B. variable
C. Object
D. Boolean
Question 4
Which of the following is NOT a comparison operator in JavaScript?
A. ===
B. !==
C. " "
D. <=
A. ===
B. !==
C. " "
D. <=
Question 5
Which of the following is NOT a data type used in programming?
A. Variables
B. Numbers
C. Booleans
D. Strings
A. Variables
B. Numbers
C. Booleans
D. Strings
Question 6
In programming, we use these to store data that we later want to access.
A. Variables
B. Numbers
C. Booleans
D. Strings
A. Variables
B. Numbers
C. Booleans
D. Strings
Question 7
Q: Which of the following returns 'he'?
A. 'hello world'.substring(0,2);
B. 'hello world'.(substring 1,3);
C. 'hello world'.substring(0,1);
D. 'hello world'.substring(1,2);
A. 'hello world'.substring(0,2);
B. 'hello world'.(substring 1,3);
C. 'hello world'.substring(0,1);
D. 'hello world'.substring(1,2);
Question 8
This data type uses quantities. You can do math with them.
A. Variables
B. Numbers
C. Booleans
D. Strings
A. Variables
B. Numbers
C. Booleans
D. Strings
Question 9
This data type is either true or false, either 0 or 1.
A. Variables
B. Strings
C. Booleans
D. Modulos
A. Variables
B. Strings
C. Booleans
D. Modulos
Question 10
If 3 > 4 === false
The above line of code is an example of what data type?
A. Boolean
B. Variable
C. String
D. Modulo
The above line of code is an example of what data type?
A. Boolean
B. Variable
C. String
D. Modulo
Question 11
This data type can be made up of letters, spaces, and even numbers. They are always surrounded by quotation marks.
A. Boolean
B. Variable
C. String
D. Modulo
A. Boolean
B. Variable
C. String
D. Modulo
Question 12
"Booleans are cool" is an example of what data type?
A. Variables
B. Numbers
C. Booleans
D. Strings
A. Variables
B. Numbers
C. Booleans
D. Strings
Question 13
This is much like a variable in that it stores a value for later use. However, while a variable can only store one value, one of these can store many.
A. String
B. Modulo
C. Array
D. Boolean
A. String
B. Modulo
C. Array
D. Boolean
Question 14
If (12 % 5 === 2)
The above line of code is an example of what?
A. String
B. Modulo
C. Array
D. Variable
The above line of code is an example of what?
A. String
B. Modulo
C. Array
D. Variable
Question 15
var favoriteMovieCandy = ["hot tamales", "nerds", "mike and ikes", ];
The above line of code is an example of what?
A. Function
B. Object
C. Modulo
D. Array
The above line of code is an example of what?
A. Function
B. Object
C. Modulo
D. Array
Question 16
var me = {
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
The above lines of code are an example of what?
A. Array
B. Function
C. Object
D. Modulo
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
The above lines of code are an example of what?
A. Array
B. Function
C. Object
D. Modulo
Question 17
var jerseyNumbers = [1, 3, 10, 11, 12, 20, 23, 24, 30, 32, 34, 40, 44, 50];
The above line of code is an example of what?
A. Function
B. Object
C. Modulo
D. Array
The above line of code is an example of what?
A. Function
B. Object
C. Modulo
D. Array
Question 18
var me = {
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
In the above line of code, which of the following would be a property?
A. me
B. var
C. children
D. 3
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
In the above line of code, which of the following would be a property?
A. me
B. var
C. children
D. 3
Question 19
If I wanted to create a database of dogs for an animal shelter that included their name, species, weight, and age, what data type would be most appropriate?
A. Array
B. Object
C. Function
D. Modulo
A. Array
B. Object
C. Function
D. Modulo
Question 20
Which of the following is the correct way to log a statement to the console?
A consolelog("Hello world")
B. console.log("Hello world")
C. console.log{"Hello world"}
D. consolelog("Hello world")
A consolelog("Hello world")
B. console.log("Hello world")
C. console.log{"Hello world"}
D. consolelog("Hello world")
Question 21
Q: Which of the following will correctly comment the text?
A. / “the text” /
B. / “the text”
C. /* “the text” */
D. \\ “the text”
A. / “the text” /
B. / “the text”
C. /* “the text” */
D. \\ “the text”
Question 22
var me = {
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
In the above line of code, which of the following would be a value?
A. me
B. var
C. married
D. "yes"
firstName: "Tom",
lastName: "Jones",
age: 35,
married: "yes",
children: 3
};
In the above line of code, which of the following would be a value?
A. me
B. var
C. married
D. "yes"
Question 23
1 var greeting = function (name) {
2 console.log ("Great to see you," + " " + name);
3 };
4 greeting(name);
The code above is meant to print out the name of a person and stick it at the end of the “Great to see you.” phrase. However, the code does NOT accomplish that. What would need to be changed in the code to make it print out the name Billy at the end of that phrase?
A. In line 1, change name to Billy.
B. In line 4, change name to Billy.
C. In line 1, change name to “Billy”.
D. In line 4, change name to “Billy”.
2 console.log ("Great to see you," + " " + name);
3 };
4 greeting(name);
The code above is meant to print out the name of a person and stick it at the end of the “Great to see you.” phrase. However, the code does NOT accomplish that. What would need to be changed in the code to make it print out the name Billy at the end of that phrase?
A. In line 1, change name to Billy.
B. In line 4, change name to Billy.
C. In line 1, change name to “Billy”.
D. In line 4, change name to “Billy”.
Question 24
1 var speed = 25;
2
3 if (speed != 25 ) {
4 console.log("Slow down");
5 }
5 else {
6 console.log ("Thank You");
7 }
A town sets up a speed limit sign (think main street of Lowell) to warn drivers if they are going faster than 25 and to thank them if they are going 25 or slower. The code above does not accomplish that. What would need to be changed in the code to make it work?
A. Change the = in line 1 to >.
B. Change the != in line 3 to >.
C. Change the speed in line 1 to 26.
D. Change the speed in line 3 to 26.
2
3 if (speed != 25 ) {
4 console.log("Slow down");
5 }
5 else {
6 console.log ("Thank You");
7 }
A town sets up a speed limit sign (think main street of Lowell) to warn drivers if they are going faster than 25 and to thank them if they are going 25 or slower. The code above does not accomplish that. What would need to be changed in the code to make it work?
A. Change the = in line 1 to >.
B. Change the != in line 3 to >.
C. Change the speed in line 1 to 26.
D. Change the speed in line 3 to 26.
Question 25
if ("Art Page".length <= 10) {
console.log("You have a short name.");
}
else {
console.log("You have a long name.");
}
What would the above code print?
A. "Art Page"
B. Numbers between 0 and 10
C. "You have a short name."
D. "You have a long name."
console.log("You have a short name.");
}
else {
console.log("You have a long name.");
}
What would the above code print?
A. "Art Page"
B. Numbers between 0 and 10
C. "You have a short name."
D. "You have a long name."