Javascript Flashcards

1
Q

Key steps for variables

A

declaration: let, var, const
assignment: age = 25

let age = 25

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

variable conventions in Javascript is …

A

camelCase
eg. let numberOfApples = 9

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

Strings

A

stores text, string is surrounded with quotes ( ‘ ‘, “”, ``)

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

Numbers

A

Represent numerical data, integer or float (float means it has decimals)

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

Logical Operators

A

== (comparing the value only if equal)
!= (not equal in value)
!== (not equal in value and type)
=== (strictly equal in value and type)

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

Conditional Syntax

A

if ( condition is true) {
// do cool stuff
}

eg.

const pizza = “Dominos”

if (pizza === “Papa Johns”) {
console.log(“Scram”)
} else if(pizza === “Dominos”) {
console.log(“You got that right”)
} else {
console.log(“What you doing?”)
}

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

Multiple Conditions

A

OR
if (day === “Saturday” || day === “Sunday”) {
//it is the weekend.
}

AND
if (day === “Saturday” && day === “Sunday”) {
//it is the weekend.
}

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

Example of a Function Declaration

A

function sayHi() {
alert(‘Hello’)
}

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

Example of a Function Expression

A

let sayHi = function() {
alert(‘Hello’);
};

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

Example of an Arrow Function

A

sayHi = () => alert(‘Hello’);

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

What is a while loop?

A

A while loop lets you repeat a code while a certain condition is true.

The while loop repeats statements while a certain condition is true.

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

Example of a while loop

A

let number = 1;
while (number <= 5) {
console.log(number);
number++;
}

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

What is the while loop syntax?

A

while(condition) {

//this is called the body
// Code to run while the condition is true

}

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

What is an example of for loop?

A

let number;
for (number =1; number <= 5; number++) {
console.log(number);
}

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

What is the for loop syntax?

A

for (initialization; condition; final expression) {

// code to run while the condition is true

}

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

What is the meaning of initialization on for loop?

A

Initialization only happens once, when the code first kicks off. It’s often used to set the initial value of the variable associated to the loop condition.

17
Q

What is the meaning of the condition on for loop?

A

The condition is evaluated once before the loop runs each time. If it’s true, the code runs. If not, the code doesn’t run.

The for loop gives the ability to manage what happens just before the loop starts and after each loop iteration has run.

18
Q

What is the meaning of the final expression on for loop?

A

The final expression is evaluated after the loop runs each time. It’s often used to update the value of the variable associated with the loop condition, as we saw in the previous example.

19
Q

What does iteration mean?

A

Each repetition in your code.

20
Q

What are loops used for?

A

It is used to repeat a series of statements.

21
Q

How to create a form in HTML?

A

<form>
<label> First Name:</label>
<input></input><br></br>
</form>

22
Q

Example of Javascript

A

HTML FILE

<h1>Your Name</h1>

<form>
<label>First Name</label>
<input></input>
</form>

<button>Yell</button>

<h2></h2>

JAVASCRIPT FILE

document.querySelector(‘#yell’).addEventListener(‘click’, yell)
function yell() {
const fName = document.querySelector(‘#firstName’).value;
const upperCaseName = fName.toUpperCase();
document.querySelector(‘#placeToYell’).innerText = upperCaseName;
}

23
Q

What are variables?

A

Are buckets.
We can tell our program to remember values for us to use later on.
The entity we use to store the value is called a variable