Week 1 Flashcards

1
Q

Name 3 variable keywords.

A

var
let
const

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

What is a variable?

A

A variable is a named container used for storing data or values.

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

Write an example of a variable.

A

let fruit = ‘apple’;

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

Is var hello = ‘hello’; the same as var Hello = ‘hello’; ?

A

Nope! Variable naming is case sensitive.

var hello is a different variable than var Hello.

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

When do we use the keyword ‘const’?

A

We use the keyword ‘const’ to create a variable of which we don’t want the value to be able to be changed or altered at any given time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
Deconstruct the following variable example: 
let b = 1;

What are the names of the 4 components that create a variable?

A

1 - Keyword
2 - Variable Name
3 - Assignment Operator
4 - Variable Value

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

What does the left hand side of a variable refer to?

let x ;

A

The left hand side of a variable is called the ‘declaration’. It is simply the variable keyword and the variable name.

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

What does the right hand side of a variable refer to?

x = 10 ;

A

The right hand side of a variable is called the ‘initialization’. It includes the variable name, assignment operator, and the value of the variable.

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

Name the 6 basic data types in JavaScript we covered in class and write an example for each of them.

A
  1. Boolean: let boolean = true;
  2. Number: let num = 14;
  3. String: let string = ‘Hello’;
  4. Null: let nothing = null;
  5. Undefined: let undef = undefined;
  6. Object: let food = [‘pizza’, ‘shrimp’];
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does JavaScript use to join strings?

A

In JavaScript, we can use concatenation to join strings together to build sentences.

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

Which method uppercases all the letters in a string?

A

Methods are tools that allow us to manipulate data.

myName.toUpperCase( ) ;

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

How do you make a directory through the command line?

A

mkdir

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

How do you check what folders you can access in the command line?

A

ls (for mac)

dir (for pc)

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

How do you change directories in the command line?

A

cd

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

How do you back up one directory in the command line?

A

cd ..

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q
What data type is this an example of?
let example = 'Hello';
17
Q
What data type is this an example of?
let example = 0;
18
Q
What data type is this an example of?
let example = true;
19
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;
}
20
Q

What will the following console log?

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

What will the following console log?

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

What will the following console log?

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

Subtraction assignment operator

24
Q

Addition assignment operator

25
Multiplication assignment operator
x *= 1
26
Division assignment operator
x /= 1
27
Remainder (or modulus) operator
x %= 1
28
Exponential assignment operator
x **= 1
29
Equal comparison operator
==
30
Strict equal comparison operator
===
31
Not equal comparison operator
!=
32
Strict not equal comparison operator
!==
33
And comparison operator
&&
34
Or comparison operator
||
35
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.') ```
36
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') } ```