1.
Var numbers = [1, 2, 3]
is an example of:
Correct Answer
A. Array
Explanation
An array is a special variable which can hold more than one value at a time.
See Codecademy lesson
2.
Var = myName
is an example of a
Correct Answer
A. Variable
Explanation
variables are used to hold values or expressions
See Codecademy lesson
3.
Select which of the options below are data types
Correct Answer(s)
A. Number
B. String
D. Boolean
Explanation
The three data types are number, string and Boolean.
See Codecademy lesson
4.
I++
Correct Answer
A. Incrementor
Explanation
Incrementors/Decrementors are used to increase/reduce the value of a variable by 1
See Codecademy lesson
5.
Var i;
for (i = 0; i < 2; i++) {
console.log("i is now equal to " + i);
Correct Answer
C. For Loop
Explanation
In JavaScript, there are two different kind of loops:
for - loops through a block of code a specified number of times
while - loops through a block of code while a specified condition is true
See Codecademy lesson
6.
is an example of a
Correct Answer
C. Function
Explanation
A function contains code that will be executed by an event or by a call to the function.
See Codecademy lesson:
7.
Var i = 0;
while ( i < 2 ) {
console.log( "i is now " + i );
i++;
}
Correct Answer
A. While Loop
Explanation
In JavaScript, there are two different kind of loops:
for - loops through a block of code a specified number of times
while - loops through a block of code while a specified condition is true
See Codecademy lesson
8.
if (name.length > 0) {
console.log("Please enter your name.");
} else {
console.log("Hello " + name);
}
is an example of:
Correct Answer
B. If...Else Statement
Explanation
If the condition (name.length>0) is true, statement1 will be executed. Otherwise, statement2 will be executed.
See Codecademy lesson
9.
switch (GPA){
case 90:
letterGrade = "A+";
break;
case 80:
letterGrade = "A";
break;
case 70:
letterGrade = "C";
break;
case 60:
letterGrade = "D";
break;
case 50:
letterGrade = "E";
break;
default:
letterGrade = "F";
break;
}
Correct Answer
D. Switch Statement
Explanation
Switch statements are a shorthand way to write if else statements when there are many different cases, and each case has a different outcome.
See Codecademy lesson
10.
is an example of
Correct Answer
D. Ternary Operator
Explanation
Ternary operators are a shorthand way of writing if else statements.
See Codecademy lesson
11.
For the object below, what does the word 'name' represent?
var dog = {name: "Daisy", age: 6};
Correct Answer
A. Property
Explanation
In this object, 'name' is a property. A property is a type of information that describes the object and is always paired with a value.
Objects can written in two different ways, depending on how the properties are defined within them:
1. Object Literal Notation:
2. Object Constructor Notation
In addition to representing properties in two different ways when creating an object, you can also access properties two different ways:
1. Dot Notation
2. Bracket Notation:
See Codecademy lesson
12.
Var dog = (); dog.name = "Daisy"; dog.age = 6;
is an example of creating an object using:
Correct Answer
B. Object Constructor Notation
Explanation
Objects can written in two different ways, depending on how the properties are defined within them:
1. Object Literal Notation:
2. Object Constructor Notation
In addition to representing properties in two different ways when creating an object, you can also access properties two different ways:
1. Dot Notation
2. Bracket Notation:
See Codecademy lesson
13.
is an example of creating an object using:
Correct Answer
B. Object Literal Notation
Explanation
Objects can written in two different ways, depending on how the properties are defined within them:
1. Object Literal Notation:
2. Object Constructor Notation
In addition to representing properties in two different ways when creating an object, you can also access properties two different ways:
1. Dot Notation
2. Bracket Notation:
See Codecademy lesson
14.
Var dogName = dog.name
is an example of accessing an object's property using:
Correct Answer
A. Dot Notation
Explanation
When you access a property, you are setting a variable equal to the the value of a property in a particular object.
In this example, we are setting variable dogName equal to the value of the 'name' property of the 'dog' object.
See Codecademy lesson
15.
is an example of accessing an object's property using:
Correct Answer
B. Bracket Notation
Explanation
When you access a property, you are setting a variable equal to the the value of a property in a particular object.
In this example, we are setting variable dogName equal to the value of the 'name' property of the 'dog' object.
See Codecademy lesson
16.
is an example of a:
Correct Answer
D. Function
Explanation
A function contains code that will be executed by an event or by a call to the function. In this case, we would call the function by writing a command: hello(); which would display the text "i am saying hello" in the console.
See Codecademy lesson
17.
In the function below, what does the text '(w, l)' represent?
var area = function (w, l) {
return w * l;
};
Correct Answer
B. Parameters
Explanation
A parameter is a variable that is processed by the function to generate a given result. In this case, if we run the function as follows: area(2,3); we will get a result of 6. To further clarify, parameters are the variables in the declaration of a function (w,l) while arguments are the specific values that get passed when running the function (2,3)
See Codecademy lesson