Assignment Operators, Comparison Operators, Conditionals, and Ternaries Flashcards

1
Q
What data type is this an example of?
let example = 'Hello';
A

String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
What data type is this an example of?
let example = 0;
A

Integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
What data type is this an example of?
let example = true;
A

Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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!")
}
A
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;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What will the following console log?

let test = '3';
if (test === 3){
  console.log('Yep!')
} else {
  console.log('Nope!')
}
A

Nope!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What will the following console log?

let test = 3;
if (test === 3){
  console.log('Yep!')
} else {
  console.log('Nope!')
}
A

Yep!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What will the following console log?

let test = '3';
if (test == 3){
  console.log('Yep!')
} else {
  console.log('Nope!')
}
A

Yep!

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Objects are ‘____’ - ‘____’ pairs

A

key-value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Subtraction assignment operator

A

x -= 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Addition assignment operator

A

x += 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Multiplication assignment operator

A

x *= 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Division assignment operator

A

x /= 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Remainder (or modulus) operator

A

x %= 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Exponential assignment operator

A

x **= 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Equal comparison operator

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Strict equal comparison operator

A

===

17
Q

Not equal comparison operator

A

!=

18
Q

Strict not equal comparison operate

A

!==

19
Q

And comparison operator

A

&&

20
Q

Or comparison operator

A

||

21
Q

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.

A
let num = 9;
(num < 11 &amp;&amp; num > 0) ? console.log('It worked!') : console.log('It didn\'t work.')
22
Q

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”

A
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')
}