What data type is "42"?
String
What is wrong?
function add(num1, num2) return num1 + num2; }
Missing { after declaration
What is an if statement used for?
To make decisions in code based on conditions.
What is an array used for?
To store multiple values in one variable
What is an object?
A collection of properties and their values
What is outputted to the console:
const num = 17;
const num2 = "17"
console.log(num+num2);
1717
What are parameters?
Inputs of a function
What is outputted to the console?
let x = 5; let y = 10; console.log(x > 3 && y > 20);
False
What is an index?
The position of an item in an array.
What is a method?
A function inside an object.
What is a variable used for?
A container used to store data values
What is a function?
A reusable block of code that performs a task.
Difference between || and &&?
|| (or) is true if one or both conditions are true
&& (and) is true only if both conditions are true
What is wrong with this code:
for(let i = 0; i <= 5; i--){
console.log(i);
}
Counter decreases but condition increases
infinite loop
What's wrong?
const person = {
name: "Alex"
age: 20
};
Missing comma between properties
Difference between = and ===?
= assigns a value
=== compares value and type
What does it mean to call a function?
To run or execute the function
Difference between == and ===?
== Compares values after type conversion (coercion)
=== Compares both value and data type
What is outputted to the console:
let nums = [2, 17, 9, 23, 4, 6, 7, 0, 6];
for(let i = 0; i < nums.length; i=i+2){
console.log(nums[i]);
}2
9
4
7
6
What is the top-level object in the DOM?
document
What will be printed to the console?
let x = 10; let y = "5"; console.log(typeof (x + y));
console.log(typeof x + y);
string
number5
Write a function that squares a number
function square(num){
return num * num;
}
What is outputted to the console? let x = 5; let y = 10; let z = 3; console.log((x < z || y == "10") && x === "5");
False
What is outputted to the console:
let nums = [15, 4, 12, 19, 1, 31, 14, 9, 26];
for(let i = 1; i < nums.length-1; i++){
if(nums[i]>10) {
console.log(nums[i]);
{
}12
19
31
14
Write a line of JavaScript that stores the DOM element with the id "thisDiv" in a variable
const thing = document.getElementById("thisDiv");