JavaScript Test A
Question 1
Which of the following would print out the length of Billy's name?
A. console.log("Billy".length);
B. print (Billy.length);
C. print.length("Billy");
D. console.log(length."Billy")
A. console.log("Billy".length);
B. print (Billy.length);
C. print.length("Billy");
D. console.log(length."Billy")
Question 2
“Blue is my favorite color.” is an example of a …?
A. string
B. variable
C. Object
D. Boolean
A. string
B. variable
C. Object
D. Boolean
Question 3
What symbols are used to comment or cancel out code.
A. &&
B. !=
C. " "
D. //
A. &&
B. !=
C. " "
D. //
Question 4
if ( "Billy Anderson".length <= 10) {
console.log("You have a short name.");
}
else {
console.log("You have a long name.");
}
What would the above code print?
A. "Billy Anderson"
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. "Billy Anderson"
B. Numbers between 0 and 10
C. "You have a short name."
D. "You have a long name."
Question 5
Which of the following is NOT a comparison operator in JavaScript?
A. ===
B. !==
C. " "
D. <=
A. ===
B. !==
C. " "
D. <=
Question 6
Which of the following is NOT a data type used in programming?
A. Strings
B. Numbers
C. Booleans
D. Variables
A. Strings
B. Numbers
C. Booleans
D. Variables
Question 7
This data type uses quantities. You can do math with them.
A. Strings
B. Numbers
C. Booleans
D. Variables
A. Strings
B. Numbers
C. Booleans
D. Variables
Question 8
In programming, we use these to store data that we later want to access.
A. Strings
B. Variables
C. Booleans
D. Modulos
A. Strings
B. Variables
C. Booleans
D. Modulos
Question 9
This data type is either true or false, either 0 or 1.
A. Strings
B. Variables
C. Booleans
D. Modulos
A. Strings
B. Variables
C. Booleans
D. Modulos
Question 10
This data type can be made up of letters, spaces, and even numbers. They are always surrounded by quotation marks.
A. Strings
B. Variables
C. Booleans
D. Modulos
A. Strings
B. Variables
C. Booleans
D. Modulos
Question 11
"Hello World!" is an example of what data type?
A. String
B. Variable
C. Boolean
D. Number
A. String
B. Variable
C. Boolean
D. Number
Question 12
If 5 > 4 === true
The above line of code is an example of what data type?
A. String
B. Variable
C. Boolean
D. Modulo
The above line of code is an example of what data type?
A. String
B. Variable
C. Boolean
D. Modulo
Question 13
If (10 % 2 === 0)
The above line of code is an example of what?
A. String
B. Variable
C. Array
D. Modulo
The above line of code is an example of what?
A. String
B. Variable
C. Array
D. Modulo
Question 14
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. Array
B. Modulo
C. String
D. Boolean
A. Array
B. Modulo
C. String
D. Boolean
Question 15
var multiplesOfEight = [8,16,24,32,40,58];
The above line of code is an example of what?
A. Function
B. Object
C. Array
D. Modulo
The above line of code is an example of what?
A. Function
B. Object
C. Array
D. Modulo
Question 16
var groceryList = ["milk", "eggs", "cheese"];
The above line of code is an example of what?
A. Function
B. Object
C. Array
D. Modulo
The above line of code is an example of what?
A. Function
B. Object
C. Array
D. Modulo
Question 17
var me = {
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
The above lines of code are an example of what?
A. Object
B. Function
C. Array
D. Modulo
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
The above lines of code are an example of what?
A. Object
B. Function
C. Array
D. Modulo
Question 18
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. Function
C. Object
D. Modulo
A. Array
B. Function
C. Object
D. Modulo
Question 19
var me = {
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
In the above line of code, which of the following would be a property?
A. me
B. firstName
C. "Jimmy"
D. var
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
In the above line of code, which of the following would be a property?
A. me
B. firstName
C. "Jimmy"
D. var
Question 20
var me = {
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
In the above line of code, which of the following would be a value?
A. me
B. firstName
C. "Jimmy"
D. var
firstName: "Jimmy",
lastName: "Anderson",
age: 25,
married: "no"
};
In the above line of code, which of the following would be a value?
A. me
B. firstName
C. "Jimmy"
D. var
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
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 23
Q: Which of the following returns 'hello'?
A. 'hello world'.substring(1,6);
B. 'hello world'.(substring 1,5);
C. 'hello world'.substring(0,7);
D. 'hello world'.substring(0,5);
A. 'hello world'.substring(1,6);
B. 'hello world'.(substring 1,5);
C. 'hello world'.substring(0,7);
D. 'hello world'.substring(0,5);
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 3 to >.
B. Change the = in line 1 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 3 to >.
B. Change the = in line 1 to >.
C. Change the speed in line 1 to 26.
D. Change the speed in line 3 to 26.
Question 25
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 Tommy at the end of that phrase?
A. In line 1, change name to Tommy.
B. In line 4, change name to Tommy.
C. In line 1, change name to “Tommy”.
D. In line 4, change name to “Tommy”.
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 Tommy at the end of that phrase?
A. In line 1, change name to Tommy.
B. In line 4, change name to Tommy.
C. In line 1, change name to “Tommy”.
D. In line 4, change name to “Tommy”.