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';
A

String

17
Q
What data type is this an example of?
let example = 0;
A

Integer

18
Q
What data type is this an example of?
let example = true;
A

Boolean

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

Nope!

21
Q

What will the following console log?

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

Yep!

22
Q

What will the following console log?

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

Yep!

23
Q

Subtraction assignment operator

A

x -= 1

24
Q

Addition assignment operator

A

x += 1

25
Q

Multiplication assignment operator

A

x *= 1

26
Q

Division assignment operator

A

x /= 1

27
Q

Remainder (or modulus) operator

A

x %= 1

28
Q

Exponential assignment operator

A

x **= 1

29
Q

Equal comparison operator

A

==

30
Q

Strict equal comparison operator

A

===

31
Q

Not equal comparison operator

A

!=

32
Q

Strict not equal comparison operator

A

!==

33
Q

And comparison operator

A

&&

34
Q

Or comparison operator

A

||

35
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.')
36
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')
}