String, Number, Boolean
What is the first index of an array?
0
____________allow us to perform different actions in our code depending on whether a condition is true or false
If Statements or Conditionals
Objects use a _______ loop to iterate
for-in
Given the function:
function multiply(x, y) {
return x * y;
}
How would you call the function to give you the product of 5 times 3?
multiply(5, 3);
____________________ is the process of accessing values in an Array using a loop.
Iteration
What is the value of array.length?
4
Which of the following will return the value true?
a) (5 + 3) / 2 === 2
b) (10 * 2) % 4 === 5
c) "Coding".length === 6
for (var i = 0; i < 5; i++) {}
How many time will this loop run and what are the values of i?
It will run 5 times
and
i will be the values 0, 1, 2, 3, 4, 5
What is logged to the console after running this code?
function add(num1, num2) {
console.log(num1 + num2);
}
Nothing, there is no function call.
A _____________ is a re-usable block of code that can accept input and returns a value.
Function
Arrays use _______ Notation to access individual elements.
Bracket
What will be the value of result aafter the function is called?
function greaterThan(num1, num2) {
if (num1 > num2) {
return num1;
}
else if (num1 < num2) {
return num2;
}
else {
console.log("They're equal");
}
}
var result = greaterThan(12, 10);
12
for (var i = 0; i <=20; i += 2) {}
How many time will this loop run and what are the values of i?
It will run 11 times and i will be the values:
0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
What is the parameter in the code snippet below:
function printForecast(weather) {
if(weather === "cloudy") {
var message = "nice day if you're a duck!";
} else if (weather === "sunny") {
var message = "nice day, eh?";
} else {
var message = "enjoy your day, no matter what!";
}
console.log(message);
}
printForecast("rainy");
weather
a) What does HTML stand for?
b) What does CSS stand for?
Hypertext Markup Language
Cascading Style Sheets
Imagine you had an array named states, how would you access the last element in the states array using bracket notation?
states[states.length-1];
var lang = "Eng";
if (lang !== "es") {
console.log("Hello, World");
}
else {
console.log("Hola, Mundo");
}
What is printed to the console after running this code?
"Hello, World"
for (var i = 5; i >1; i--) {}
How many time will this loop run and what are the values of i?
It will run 4 times and i will be the values:
5, 4, 3, 2
What are the arguments in the code snippet below:
function foo(num1, num2) {
if (num1 < num2) {
return num2;
} else {
return num1;
}
}
var result = foo(5, 10);
5 and 10
What are the 3 simple data types?
What are the 2 complex data types?
String, Number, Boolean
Objects and Arrays
var grades = [85, 67, 93, 79, 88, 72, 59, 95, 76];
Create a for loop that would use iteration to print each element of the array in the console.
for (var i = 0; i < grades.length; i++) {
console.log(grades[i]);
}
Create a function named isEven with 1 parameter called number.
The function should return true if number is an even number, false otherwise.
function isEven(number) {
if (x % 2 === 0) {
return true;
}
else {
return false;
}
}
Which of the following loops creates an infinite loop?
a) for (var i = 0; i < 10; i++) { }
b) for (var i = 0; i < 10; i--) { }
c) for (var i = 10; i > 0; i--) { }
B
Create a function named add that has two parameters, x and y.
add should return the sum of the two numbers
function add(x, y) {
return x + y;
}