What data type is this an example of? let example = 'Hello';
String
What data type is this an example of? let example = 0;
Integer
What data type is this an example of? let example = true;
Boolean
Rewrite the following as a Switch:
let test = 5;
if (typeof test === 'string') {
console.log("It's a string!");
} else if (typeof test === 'number') {
console.log("It's a number!");
} else if (typeof test === 'boolean') {
console.log("It's a boolean!");
} else {
console.log("It's something else!")
}switch (typeof test) {
case 'string':
console.log("It's a string!");
break;
case 'number':
console.log("It's a number!");
break;
case 'boolean':
console.log("It's a boolean!");
break;
default:
console.log("It's something else!");
break;
}What will the following console log?
let test = '3';
if (test === 3){
console.log('Yep!')
} else {
console.log('Nope!')
}Nope!
What will the following console log?
let test = 3;
if (test === 3){
console.log('Yep!')
} else {
console.log('Nope!')
}Yep!
What will the following console log?
let test = '3';
if (test == 3){
console.log('Yep!')
} else {
console.log('Nope!')
}Yep!
Objects are ‘____’ - ‘____’ pairs
key-value
Subtraction assignment operator
x -= 1
Addition assignment operator
x += 1
Multiplication assignment operator
x *= 1
Division assignment operator
x /= 1
Remainder (or modulus) operator
x %= 1
Exponential assignment operator
x **= 1
Equal comparison operator
==
Strict equal comparison operator
===
Not equal comparison operator
!=
Strict not equal comparison operate
!==
And comparison operator
&&
Or comparison operator
||
Write a ternary that console logs “It worked!” if a number is between 1 and 10 and console logs “It didn’t work” if it is not.
let num = 9;
(num < 11 && num > 0) ? console.log('It worked!') : console.log('It didn\'t work.')Write an else if statement that checks the variable weather. If it is hot console log “Wear a t-shirt”, if it is cold console log “wear a coat” and if it is rainy console log “bring an umbrella”
let weather = 'cold';
if (weather === 'rainy'){
console.log('Bring an umbrella')
} else if (weather === 'hot') {
console.log('Wear a t-shirt')
} else if (weather === 'cold') {
console.log('Wear a coat')
}