All Cards Flashcards

1
Q

Where do you put non-visible content about the HTML document?

A

In the head element

(Meta data e.g. Title are in the head element)

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

Where do you put visible content about the HTML document?

A

In the body element

E.g. h1-h6, p, ul, ol, li elements

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

Where do the head and body tags go in a valid HTML document?

A

In the html element (head element is above the body element)

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

What is the purpose of a DOCTYPE declaration?

A

To tell the browser what type of document is being used

(specifically with HTML it was used for which version of HTML was being used)

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

Give five examples of HTML element types.

A

head
body
h1 - h6
p
ul
ol
li
div

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

What is the purpose of HTML attributes?

A

To provide additional information on the content of an element

E.g. Class, ID, src…

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

Give an example of an HTML entity (escape character).

A

Less Than <
Greater Than >
Ampersand &
Cent ¢
Pound £
Yen ¥
Euro €
Copyright ©
Registered trademark ®
Trademark ™
Multiplication ×
Division ÷

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

How do block-level elements affect the document flow?

A

Block level elements always start on a new line. They do not allow any other elements on the same line as them.

Example Block Elements:
ul
ol
li
h1-h6
p
div

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

How do inline elements affect the document flow?

A

Inline elements will continue on the same line. They allow other elements to be on the same horizontal line.

Example Inline Elements:
button
span
strong
em

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

What are the default width and height of a block-level element?

A

Width: width of its containing block

Height: height of content

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

What are the default width and height of an inline element?

A

Width: width of content

Height: height of content

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

What is the difference between an ordered list and an unordered list in HTML?

A

An ordered list numbers each line in ascending order and an unordered list shows each item next to a bullet point.

OL:
1.
2.
3.

-
-

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

Is an HTML list a block element or an inline element?

A

Block element because it lists each item on its own line.

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

What HTML tag is used to link to another website?

A

Anchor Tag (the a element)

a href=”link”

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

What is an absolute URL?

A

An absolute URL is a link to a specific URL on the web (can be a completed different website [href is the full web address] )

E.g.
a href=”https://www.google.com”

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

What is a relative URL?

A

A relative URL is a link to other pages within the same site (href does not need the domain name)

E.g.
a href=”index.html”

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

“What is the internet?”

A

The internet is a global network of computers that are connected to each other. Every computer on the public Internet has an IP address

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

“How does the web work?”

A
  1. Your browser needs to know what a domain name means. A DNS (domain name system) lookup is performed to translate the domain name into an IP address.
  2. The browser then opens a TCP connection to the computer at the IP address.
  3. The browser then sends an HTTP request to the computer at the IP address.
  4. The browser receives a response from the computer at that IP address (originally this was an HTML document).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do you indicate the relative link to a parent directory?

A

WIth ../

Example:
href=”../filename”

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

How do you indicate the relative link to a child directory?

A

With the folder name / file name

Example:
href=”foldername/filename”

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

How do you indicate the relative link to a grand parent directory?

A

You use a ,,/ for each directory you want to move up (grandparent is 2 directories above so 2 ../)

Example:
href=”../../filename”

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

How do you indicate the relative link to the same directory?

A

You can just link the file name.

Example:
href=”filename”

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

What is the purpose of an HTML form element?

A

The HTML form element houses the section of the HTML document that contains interactive controls for submitting information

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

Give five examples of form control elements.

A

Button
Input - the input type is noted in the type attribute
Select - used to create a dropdown selection element
option - used to provide options for the dropdown selection element
textarea - used to provide a block to input larger amounts of text in

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

Give three examples of type attribute values for HTML input elements.

A

Radio - circular select button
Checkbox
text
password - text input that hides the text
submit
file
image

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

Is an HTML input element a block element or an inline element?

A

It is an inline block element. Even though it puts information on the same line, because the height and width can be adjusted it gives it properties of a block element.

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

What are the six primary HTML elements for creating tables?

A

Table
thead
tr
th
tbody

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

What purpose do the thead and tbody elements serve?

A

The thead element is used to define the row of elements at the top of the table (essentially column names) whereas the tbody element is used to define the content of the table.

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

Give two examples of data that would lend itself well to being displayed in a table.

A

Students & Grades, Items & Pricing, Schedules, Information checkboxes

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

What are the names of the individual pieces of a CSS rule?

A

Start of a new CSS rule set:
[selector] { start of declaration block
property : value ;
} end of declaration block

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

In CSS, how do you select elements by their class attribute?

A

To select an element by their class attribute you preface the class name with a .

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

In CSS, how do you select elements by their tag name?

A

To select an element by its tag name you just use the tag name as the selector

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

In CSS, how do you select an element by its id attribute?

A

To select an element by their id attribute you preface the id name with a #

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

Name three different types of values you can use to specify colors in CSS.

A

Color Name - e.g. White, Black, Blue

Hex Code - e.g. #ffffff

RGB Value - e.g. rgb(255 255 255);

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

What CSS properties make up the box model?

A

The content (length and width)
Padding (space between content and border)
Border
Margin (space between border and other boxes)

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

Which CSS property pushes boxes away from each other?

A

The margin property

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

Which CSS property add space between a box’s content and its border?

A

The padding property

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

What is a pseudo-class?

A

A pseudo class is a keyword added to selector that specifies a special state of the selected element. Pseudo-classes let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors e.g. :hover (when element is hovered) :active (when the element is in use such as a click)

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

What are CSS pseudo-classes useful for?

A

CSS pseudo-classes are useful for providing feedback to the user (e.g. form elements [buttons active/inactive states] or hyperlinks [visited or not])

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

Name two types of units that can be used to adjust font-size in CSS.

A

Pixels (px), Ems (em), and percentages (%)

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

What CSS property controls the font used for the text inside an element?

A

Font-family property

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

What is the default flex-direction of a flex container?

A

The default flex-direction of a flex container is row

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

What is the default flex-wrap of a flex container?

A

The default flex-wrap of a flex container is no-wrap

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

Why do two div elements “vertically stack” on one another by default?

A

Divs are block elements which do not allow any other elements to be on the same line as them.

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

What is the default flex-direction of an element with display: flex?

A

The default flex-direction is row.

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

What is the default value for the position property of HTML elements?

A

The default value for position is static.

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

How does setting position: relative on an element affect document flow?

A

The document flow stays the same as the element still takes up the space it would normally occupy.

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

How does setting position: relative on an element affect where it appears on the page?

A

The element moves based on where it was supposed to be.

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

How does setting position: absolute on an element affect document flow?

A

Position absolute removes an element from normal document flow.

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

How does setting position: absolute on an element affect where it appears on the page?

A

The element will appear where it would normally but it may overlap or be overlapped by any elements that will go to occupy its space when it was removed from document flow.

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

How do you constrain an absolutely positioned element to a containing block?

A

You set the containing block to position relative.

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

What are the four box offset properties

A

Top, right, bottom, left

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

What is the purpose of variables?

A

Variables are used to store information for the computer to be able to reference back to. It brings permanence to data.

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

How do you declare a variable?

A

You declare a variable with the var keyword followed by the variable name. A variable can start with a letter, $, or _

var fullName

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

How do you initialize (assign a value to) a variable?

A

If a variable has not been declared yet, you use the variable keyword, the variable name, and then initialize the variable with the assignment operator =

var fullName = ‘Brandon Moy’;

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

What characters are allowed in variable names?

A

Lowercase letters, uppercase letters (camel case), numbers, $, and _

Variables cannot start with numbers

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

What does it mean to say that variable names are “case sensitive”?

A

It means that the capitalization must be consistent across the entire variable

var Score is different from var score

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

What is the purpose of a string?

A

A string it used to record a data type that lets us store any types of characters

e.g. ‘Hello World!’

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

What is the purpose of a number?

A

A data type number is recorded to recall a number value (can be used for calculations or incrementation)

var width = 10;
var height = 10;

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

What is the purpose of a boolean?

A

A boolean is used to define a value as true or false. It is used for decision making.

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

What does the = operator mean in JavaScript?

A

The = operator assigns the value on the right side to the variable on the left side

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

How do you update the value of a variable?

A

You can update a value of a variable by assigning it a new value further down the script

early: var fullName = ‘Brandon’;
later: fullName = ‘Brandon Moy’;

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

What is the difference between null and undefined?

A

Both are empty values but for different purposes. Null is a nonexistent or invalid object (cannot be used by JavaScript [can be used as a placeholder as null can ONLY be assigned]) whereas undefined is returned by JavaScript when there is no value assigned

Null - used by programmers to show empty
Undefined - JavaScript’s way to show empty

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

Labels print information on the values being logged to the console for more ease of readability

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

Give five examples of JavaScript primitives.

A

String, Numbers, Boolean, Null, Undefined

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

What data type is returned by an arithmetic operation?

A

A number data type is returned by an arithmetic operation. If a string is put through an arithmetic operation JavaScript will print back NaN (not a number)

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

What is string concatenation?

A

String concatenation is when two or more strings are combined together to create a new string.

‘Hello’ + ‘ ‘ + ‘World!’ will return as ‘Hello World!’

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

What purpose(s) does the + plus operator serve in JavaScript?

A

The + operator can be used as arithmetic operator or string concatenator

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

What data type is returned by comparing two values (<, >, ===, etc)?

A

When comparing two values a boolean is returned for the value of the comparison

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

What does the += “plus-equals” operator do?

A

The += operator adds the new value to the starting variable and then assigns this new combined value back to the variable.

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

What are objects used for?

A

Objects are used to store multiple pieces of information into location without affecting other data and multiple pieces of information into one location to call back to.

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

What are object properties?

A

Object properties are just variables assigned to one object

var objectName = {
property: propertyValue
};

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

Describe object literal notation.

A

You use the variable keyword, the variable name, and you assign a grouping of properties to it inside of { }. Each property is notated property: value and a comma is used to separate the properties.

var objectName = {
property: value,
property2: value
};

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

How do you remove a property from an object?

A

delete operator is used to remove a property

delete object.property;

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

What are the two ways to get or update the value of a property?

A

Dot notation - object.property = newValue;

Square bracket - object[‘property’] = newValue;

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

What are arrays used for?

A

Arrays are used for storing a list of data. e.g. List of students, colors, hotels, cars

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

Describe array literal notation.

A

Square bracket with value separated by a comma

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

How are arrays different from “plain” objects?

A

Objects will assign a value to a property for the key value pair while an array assigns the value to an index number for the key value pair. Arrays have set orders and length properties.

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

What number represents the first index of an array?

A

The number for the first index of an array is 0 since computers start counting from 0

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

What is the length property of an array?

A

The length property of an array is a count of how many values are stored in the array.

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

How do you calculate the last index of an array?

A

You can subtract 1 from the length of the array.

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

What is a function in JavaScript?

A

A list of steps that can be reused multiple times in the code.

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

Describe the parts of a function definition.

A

The function keyword, the (optional) name of the function, the parameter list separated by commas and surrounded by parenthesis, the open curly brace for the function block, code within the code block, probably a return

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

Describe the parts of a function call.

A

The function name, 0 or more arguments surrounded by parenthesis

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

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

The definition has { } for code block, function keyword

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

What is the difference between a parameter and an argument?

A

Parameter - used in definition, placeholder for a future value
Argument - used in function call, actually value provided

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

Why are function parameters useful?

A

Parameters allow us to create variance. They allow us to create ONE function for MULTIPLE uses

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

What two effects does a return statement have on the behavior of a function?

A

1) It allows the results to be used outside of the function
2) It stops the function

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

Why do we log things to the console?

A

We log things to the console so that developers can check and see the output and the state of variables and functions. The console is the developers way of communicating with JavaScript

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

What is a method?

A

A method is a reference to a function that is used as a property of an object. E.g. Math.max() is the max method OF the math object

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

How is a method different from any other function?

A

A method is called as a property of the object it is pulling the information off of.

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

How do you remove the last element from an array?

A

You use the .pop() method of the array object to remove the last element

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

How do you round a number down to the nearest integer?

A

You can use the .floor() method of the array object to round down to the nearest integer

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

How do you generate a random number?

A

The .random() method of the max object will generate a random number between 0 and 1 which can then be multiplied by the length of the array you want to generate randomly from

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

How do you delete an element from an array?

A

The .splice(start, quantity) can delete elements from an array

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

How do you append an element to an array?

A

You use the .push() method to append an element to an array

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

How do you break a string up into an array?

A

Use the .split() method with the argument string value ‘ ‘ to separate the string at the argument locations

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

Do string methods change the original string? How would you check if you weren’t sure

A

They do not change the original string. We can console.log() the original variable housing the string we change. Instead of changing the original string, string methods create a new string.

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

Roughly how many string methods are there according to the MDN Web docs?

A

50

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

Is the return value of a function or method useful in every situation?

A

It might not be useful in every situation so we as developers need to create situations where the functions or methods we create/use are useful

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

Roughly how many array methods are there according to the MDN Web docs?

A

A lot. . .

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

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

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

Give 6 examples of comparison operators.

A

> , <, >=, <=, ==, ===, !=. !==.

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

What data type do comparison expressions evaluate to?

A

Booleans

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

What is the purpose of an if statement?

A

If statements are used to create branching actions or decision making

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

Is else required in order to use an if statement?

A

Else is not required to use an if statement, but if the statement is false then the if statement will return undefined

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

Describe the syntax (structure) of an if statement.

A

If keyword, condition to check surrounded by parenthesis, curly brace to start code block for what to run if parameter is true, what to run if the parameter is true in the code block, closing curly brace

if (condition) {
statement
}

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

What are the three logical operators?

A

&& (and)
|| (or)
!(not)

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

How do you compare two different expressions in the same condition?

A

You can use || for or, or && for and between the two expressions but keep both of them within the same ( ) parameter

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

What is the purpose of a loop?

A

The purpose of a loop is to repeat an action

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

What is the purpose of a condition expression in a loop?

A

The condition expression in a loop allows JavaScript to know when the loop should be stopped

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

What does “iteration” mean in the context of loops?

A

An iteration is each time a loop is run. The first iteration would be the first time the loop is run and the last iteration is the final time a loop is run.

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

When does the condition expression of a while loop get evaluated?

A

The condition expression is evaluated before executing the statement in each iteration

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

When does the initialization expression of a for loop get evaluated?

A

The initialization expression of a for loop is evaluated once before the loop is begun

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

When does the condition expression of a for loop get evaluated?

A

The condition expression of a for loop gets evaluated before every iteration

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

When does the final expression of a for loop get evaluated?

A

The final expression of a for loops gets evaluated at the end of each iteration

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

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

The break keyword can exit a loop before the condition expression evaluates to false

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

What does the ++ increment operator do?

A

The ++ increment operator increases the value of the variable by 1

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

How do you iterate through the keys of an object?

A

You use a for … in loop and set a variable for the keys

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

What are the four components of “the Cascade”.

A

Source Order, Specificity, Inheritance, !Importance

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

What does the term “source order” mean with respect to CSS?

A

Source Order is the order the code is listed in the css file. The most recently added code is what is applied (the code lower on the css file)

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

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

Inheritance will apply a style of an element to its children if there is no additional CSS rule for the same style added to the child

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

List the three selector types in order of increasing specificity.

A

Type - Class - ID

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

Why is using !important considered bad practice?

A

!important reverses the cascade order for style sheets. It forces a styling to an element.

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

What does the transform property do?

A

It allows you to move elements along the x, y, and z axes. You can rotate, skew, angle… elements

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

Give four examples of CSS transform functions.

A

rotate - spins an image clockwise (negative value for counter clockwise)
translate - moves an image horizontally and vertically
scale - resizes an image on a 2D plane (can also flatten/stretch images)
skew - resizes/shapes an element on a diagonal plane
matrix -

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

The transition property is shorthand for which four CSS properties?

A

transition-property, transition-duration, transition-timing-function, and transition-delay

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

Why do we log things to the console?

A

We log things as a console both to make sure that the main.js file is interacting with the html file and so that we as developers can test and track values (debugging)

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

What is a “model”?

A

A recreation of something (generally not 1:1 recreation)

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

Which “document” is being referred to in the phrase Document Object Model?

A

The HTML document

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

What is the word “object” referring to in the phrase Document Object Model?

A

The JavaScript object data type

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

What is the DOM?

A

A JavaScript object that is modeling the contents of an HTML document that is loaded into the browser

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

What is a DOM Tree?

A

The DOM tree is a list of objects/nodes that branch off of the document node. It is made up of the different elements, attributes, and text nodes in an HTML document. It is an element plus all of its content and all of its configurations.

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

Give two examples of document methods that retrieve a single element from the DOM.

A

document.getElementbyID(‘id’);
document.querySelector(‘css selector’);

135
Q

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

document.querySelectorAll(‘css selector’);
document.getElementsByClassName(‘class’);
document.getElementsByTagName(‘tag name’);

136
Q

Why might you want to assign the return value of a DOM query to a variable?

A

In case you need to re-use that value of a DOM query multiple times

137
Q

What console method allows you to inspect the properties of a DOM element object?

A

console.dir( ); [ dir is short for directory]

138
Q

Why would a tag need to be placed at the bottom of the HTML content instead of at the top?

A

Because we want to load the content of the HTML document first?

139
Q

What does document.querySelector() take as its argument and what does it return?

A

document.querySelector( ); takes a css selector as it’s argument (in a string) and returns the first element that matches the selector

140
Q

What does document.querySelectorAll() take as its argument and what does it return?

A

document.querySelectorAll( ); takes a css selector as it’s argument (in a string) and returns all elements with that css selector (Node List)

141
Q

Why do we log things to the console?

A

We log things as a console both to make sure that the main.js file is interacting with the html file and so that we as developers can test and track values (debugging)

142
Q

What is the purpose of events and event handling?

A

Events are a way to let us know when an event occurs (usually when a user interacts with the page) and event handling is our way of preparing a response when the event occurs

143
Q

Are all possible parameters required to use a JavaScript method or function?

A

No, there are some parameters that are optional

144
Q

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

Use addEventListener to the object you want to call the event on

145
Q

What is a callback function?

A

A callback function is a function benign passed into another function as an argument

146
Q

What object is passed into an event listener callback when the event fires?

A

The event object is passed and the data is all the information of when the event was invoked

147
Q

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

The value of the element where the event occurred it is not the element that the event listener is applied on
We can check by console logging the target property of the event object
We can either check the code or MDN for more information

148
Q

What is the difference between these two snippets of code?
element.addEventListener(‘click’, handleClick)
element.addEventListener(‘click’, handleClick())

A

The first one is a callback function and the second is a function call with no argument. Because of this it runs the function with nothing but the first one will run with the event as it’s argument

149
Q

What is the className property of element objects?

A

A string of the class attribute of an element
It can get or set the className attribute on an HTML document

150
Q

How do you update the CSS class attribute of an element using JavaScript?

A

You use the .className on the variable storing the DOM information and assign it a string value of the new class name

151
Q

What is the textContent property of element objects?

A

The textContent property is the text content of a node on the DOM
Property that stores any text content that is present in the node

152
Q

How do you update the text within an element using JavaScript?

A

Use the .textContent on the variable storing the DOM information and assign it the new text you want it to have

153
Q

Is the event parameter of an event listener callback always useful?

A

No, in functions where you don’t want things to vary you do not need the event parameter
But in general we will want to use the event parameter in most cases

154
Q

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

Harder because instead of referencing a variable with the number of clicks in it, we would have to calculate the number of clicks for each spot we want to check the value of the clicks

155
Q

Why is storing information about a program in variables better than only storing it in the DOM?

A

If we store the information in a variable then the computer does not have to process getting the value multiple times and makes the work more efficient for the computer. For developers it also makes it easier to read by knowing that we are referencing back to an already stored value.

156
Q

What event is fired when a user places their cursor in a form control?

A

The focus event

157
Q

What event is fired when a user’s cursor leaves a form control?

A

The blur event

158
Q

What event is fired as a user changes the value of a form control?

A

The input event

159
Q

What event is fired when a user clicks the “submit” button within a ?

A

The submit event

160
Q

What does the event.preventDefault() method do?

A

It stops the form elements from returning to their default setting (either blank or placeholders)

161
Q

What does submitting a form without event.preventDefault() do?

A

It refreshes the page

162
Q

What property of a form element object contains all of the form’s controls.

A

The elements property

163
Q

What property of a form control object gets and sets its value?

A

The value property

164
Q

What is one risk of writing a lot of code without checking to see if it works so far?

A

You run the risk of running into a bug and not knowing where in the code it happened

165
Q

What is an advantage of having your console open when writing a JavaScript program?

A

You can check your progress and make sure everything is working the way you want it to

166
Q

Does the document.createElement() method insert a new element into the page?

A

No it does not, it just creates the element. You need to appendChild to insert the element made into the document

167
Q

How do you add an element as a child to another element?

A

With the appendChild method

168
Q

What do you pass as the arguments to the element.setAttribute() method?

A

The attribute you want to set and the value you want to assign

169
Q

What steps do you need to take in order to insert a new element into the page?

A

Create the element, append the element as the child of another element

170
Q

What is the textContent property of an element object for?

A

It is used to receive or modify the text content of an element

171
Q

Name two ways to set the class attribute of a DOM element.

A

element.className(‘new class name’);

element.setAttribute(‘class’, ‘new class name’);

172
Q

What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?

A

The return of the reusable function can be used in other places (different contexts)

173
Q

Give two examples of media features that you can query in an @media rule.

A

Width, min-width, height, orientation

174
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

The viewport meta tag

175
Q

What is the event.target?

A

The event.target is the target element that the event happens on

176
Q

Why is it possible to listen for events on one element that actually happen its descendent elements?

A

Because of event bubbling

177
Q

What DOM element property tells you what type of element it is?

A

event.target.tagName

178
Q

What does the element.closest() method take as its argument and what does it return?

A

It takes a css selector and returns the closest ancestor element (or itself) that matches the argument

179
Q

How can you remove an element from the DOM?

A

‘Item you want to remove in a DOM variable’ . remove();

180
Q

If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

Create a click on all the elements and set a conditional that if the tagName is === to the element you want to affect, then make the changes, otherwise do nothing

181
Q

What is the event.target?

A

The event.target is the property of the event object that holds the location of where the event occurred

182
Q

What is the affect of setting an element to display: none?

A

Display: none will hide all content inside of the element. The element is present but not showing any of its content

183
Q

What does the element.matches() method take as an argument and what does it return?

A

Element.matches () takes a css selector in a string as its argument and returns a boolean

184
Q

How can you retrieve the value of an element’s attribute?

A

You can use the element.getAttribute(‘attribute’)

185
Q

At what steps of the solution would it be helpful to log things to the console?

A

At every step ☺

186
Q

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

We would need to put an event listener on each tab instead of on the container with the tabs inside of it

187
Q

If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?

A

It would be written with a conditional for each tab we would need to check

188
Q

What is a breakpoint in responsive Web design?

A

A breakpoint is a spot where the web page should change its styling. Often this is used for styling for different sized screens (mobile, tablet, or desktop)

189
Q

What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?

A

Using a % allows the content to scale with the size of the page

190
Q

If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win”. Why is that?

A

Because of CSS cascade (source order) the “newest” ruleset (closest to the bottom) will be applied over previous rules

191
Q

What is JSON?

A

JSON (JavaScript Object Notation) is a way to store the contents of an object in a string most commonly used to transmit data to a web page

192
Q

What are serialization and deserialization?

A

Serialization is turning an object into date (stream of bytes)
Deserialization is turning that data (stream of bytes) back into the object

193
Q

Why are serialization and deserialization useful?

A

It turns complex data into data that is understood everywhere

194
Q

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify(‘object’)

195
Q

How do you deserialize a JSON string into a data structure using JavaScript?

A

JSON.parse(‘JSON string’);

196
Q

How do you store data in localStorage?

A

Use the setItem method on the localStorage object

localStorage.setItem(‘key’, ‘key value’)

197
Q

How do you retrieve data from localStorage?

A

Use the getItem method on the localStorage object

localStorage.getItem(‘key’)

198
Q

What data type can localStorage save in the browser?

A

Strings

199
Q

When does the ‘beforeunload’ event fire on the window object?

A

Right before the tab is about to unload (closing tab, closing window, refreshing tab. . . )

200
Q

What is a method?

A

A method is a function that is a property of an object

201
Q

How can you tell the difference between a method definition and a method call?

A

A method definition will have the function keyword and variable(s) for the parameter(s) whereas a method call will be called on an object with a . between the object and method and would have a variable for the argument (if an argument is needed)

Definition: methodName: function (parameter) {
}
Call: object.method(argument)

202
Q

Describe method definition syntax (structure).

A

Method definition will have the property the method is stored in (method name), colon, function keyword, parameter(s) in parenthesis, open curly brace for the function code block, code for the function to run, closing curly brace for the function code block

property: function (parameter) {
}

203
Q

Describe method call syntax (structure).

A

You use the object you want to call the method on, then a . followed by the method name and then the argument in parenthesis

object.method(argument)

204
Q

How is a method different from any other function?

A

Methods are functions that are properties of an object whereas functions can also exist outside of an object. These functions are called differently than methods

Method call - object.methodName(argument)
Function call - functionName(argument)

205
Q

What is the defining characteristic of Object-Oriented Programming?

A

Pairing data with behavior

206
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction
Encapsulation
Inheritance
Polymorphism

207
Q

What is “abstraction”?

A

Abstraction is the idea of using something complex but being thought of in a simple way

E.g. Turning on the light - to us is flipping a switch, to electricity it is opening a circuit connected to a break to move electricity to the lightbulb

208
Q

What does API stand for?

A

Application Programming Interface

209
Q

What is the purpose of an API?

A

Its purpose is to give programmers a way to interact with a system in a simplified, consistent fashion (using abstraction)

210
Q

What is this in JavaScript?

A

this is an implicit parameter that is checked/available at the time of a function call. It is used in methods when there is information in the same object that this wants to reference

211
Q

What does it mean to say that this is an “implicit parameter”?

A

It means that this is available in a function even thought it was not declared or set as its own variable

212
Q

When is the value of this determined in a function; call time or definition time?

A

The value of this is determined when a function is called

213
Q

What does this refer to in the following code snippet?
var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

A

this refers to nothing because nothing is being called and the value is determined at call time

214
Q

var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};
Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

The result of character.greet(); should be ‘It’s-a-me, Mario!

It pulls the value of this (which is the character object) at the firstName property which is Mario

215
Q

Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();

A

this would be undefined because this would be called on the window object which does not have a firstName property

216
Q

How can you tell what the value of this will be for a particular function or method definition?

A

You cannot tell the value before it is called

217
Q

How can you tell what the value of this is for a particular function or method call?

A

Look for the object named to the left of the method call and look inside of the object, otherwise it is the window

218
Q

What kind of inheritance does the JavaScript programming language use?

A

Prototype-based inheritance (prototypal inheritance)

219
Q

What is a prototype in JavaScript?

A

A JavaScript prototype is simply an object that contains properties and (predominantly) methods that can be used by other objects.

220
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on strings, arrays, and numbers?

A

You can set an object as a prototype of another object allowing you to call the methods on those objects without them existing inside of the objects
There also prototypes already set on the objects (strings, arrays, and numbers)
Object.setPrototypeOf(object, prototype object);

221
Q

If an object does not have its own property or method by a given key, where does JavaScript look for it?

A

Inside of its prototypes

222
Q

What does the new operator do?

A

The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.

Creates a blank object

Points the newInstance’s prototype ot the constructor function’s prototype property

Executes constructor function with given arguments and stores as this

95%+ constructor function will not have a return statement which means that the newInstance gets returned instead

223
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

The [[Prototype]] property

224
Q

What does the instanceof operator do?

A

The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object.

The return is a boolean value

225
Q

What is a “callback” function?

A

A callback function is a function that is passed as an argument to another function

226
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

You can use the setTimeout() window method

227
Q

How can you set up a function to be called repeatedly without using a loop?

A

By using the setInterval() window method

228
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?

A

0
This causes JavaScript to run the function as quickly as it can

229
Q

What do setTimeout() and setInterval() return?

A

They return a unique interval ID number that is needed to clear the recurring function

230
Q

What is a client?

A

Service REQUESTERS are clients (users?) - something that is CONSUMING resources

231
Q

What is a server?

A

Service PROVIDERS are servers

232
Q

Which HTTP method does a browser issue to a web server when you visit a URL?

A

The GET method

233
Q

What three things are on the start-line of an HTTP request message?

A

HTTP method (verb like GET, PUT, POST. . . or noun like HEAD or OPTION)
-How is the request being made?
Request Target - usually a URL or absolute path
-Where is the request going?
The HTTP version (defines structure of remaining message)

234
Q

What three things are on the start-line of an HTTP response message?

A

The protocol version (usually HTTP/1.1)
The status code - indicates success or failure of request
The status text - brief, informational, textual description of the status code

235
Q

What are HTTP headers?

A

Headers are where the client and server can pass additional information with an HTTP request or response.
-General Headers - apply to the message as a whole
-Request Headers - modify the request by specifying it further, giving context, or restricting it
-Representation Headers - describe the original format of the message data

236
Q

Where would you go if you wanted to learn more about a specific HTTP Header?

A

MDN

237
Q

Is a body required for a valid HTTP request or response message?

A

A body is not required

238
Q

What is AJAX?

A

Asynchronous JavaScript and XML is a way for users to send and update responses without having to update the page. The user can continue to do other things in the browser while waiting for the data to load.

239
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

240
Q

Which object is built into the browser for making HTTP requests in JavaScript?

A

The new XMLHttpRequest(); object

241
Q

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?

A

The load event

242
Q

Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?

A

They share a the same prototype

243
Q

What is a code block? What are some examples of a code block?

A
  • A code block is the code within curly brackets { } that should run
  • Function code block, loop code block, condition code block
244
Q

What does block scope mean?

A
  • A variable when declared inside the if or switch conditions or inside for or while loops, are accessible within that particular condition or loop.
  • Tl;dr - variables declared inside of code blocks are only accessible inside those code blocks
245
Q

What is the scope of a variable declared with const or let?

A

Blocked-scope

246
Q

What is the difference between let and const?

A
  • let is a block scope variable that can be updated but the updated value is only accessible inside of code block
  • const is a block scope constant variable and it’s value cannot be reassigned
247
Q

Why is it possible to .push() a new value into a const variable that points to an Array?

A

For the same reason we can update object property values, we can update the object’s property values but we cannot update the entire object (in this case, array)

248
Q

How should you decide on which type of declaration to use?

A

Can the value be updated and reused? - let
Should the value be constant? - const

249
Q

What is the syntax for writing a template literal?

A

You would surround the template literal with backticks `

250
Q

What is “string interpolation”?

A

String interpolation is the ability to substitute part of the string for the values of variables or expressions.

251
Q

What is destructuring, conceptually?

A

Object destructing is taking an object, and then turning that object’s properties into variables

252
Q

What is the syntax for Object destructuring?

A

const { object properties separated by a comma(use : and an alias to rename variables different from property name} = objectName

253
Q

What is the syntax for Array destructuring?

A

const [array indices separated by a comma] = arrayName

254
Q

How can you tell the difference between destructuring and creating Object/Array literals?

A

The location of the assignment operator
- An object destructured object will be the variable keyword, the object literal or properties being turned into variables, the assignment operator then the objects name
- A normal object would be the variable keyword, object name, assignment operator, then the object literal

255
Q

What is the syntax for defining an arrow function?

A

Parameter (in parenthesis if more than one parameter or less than one parameter) => code to run
- If it is one expression you do not need a code block or a return statement
- But if a code block is used then a return statement is necessary

256
Q

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

It automatically returns the result of the expression

257
Q

How is the value of this determined within an arrow function?

A

It takes the value of the enclosing context to be the value of this

258
Q

What is a CLI?

A

Command Line Interface
- An interface that receives commands from the user via text

259
Q

What is a GUI?

A

Graphical User Interface
- An interface that receives commands from users via graphical icons and audio indicators

260
Q

Give a use case for the following command:
man

A

Manual lists information on a command

261
Q

Give a use case for the following command:
cat

A

Concatenates files

262
Q

Give a use case for the following command:
ls

A

Lists directory contents

263
Q

Give a use case for the following command:
pwd

A

Prints the name of the current/working directory

264
Q

Give a use case for the following command:
echo

A

Displays a line of text . . . “echoes” the text input

265
Q

Give a use case for the following command:
touch

A

Change files timestamps

266
Q

Give a use case for the following command:
mkdir

A

Makes directories

267
Q

Give a use case for the following command:
mv

A

Moves or renames files

268
Q

Give a use case for the following command:
rm

A

Removes files

269
Q

Give a use case for the following command:
cp

A

Copies files and/or directories

270
Q

What are the three virtues of a great programmer?

A

1) Laziness:
The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
2) Impatience:
The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
3) Hubris:
The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.

271
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a browser

272
Q

What can Node.js be used for?

A

It can be used to build backend Web applications, command-line programs, and automation

273
Q

What is a REPL?

A

Read-eval-print loop
- a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the use

274
Q

When was Node.js created?

A

2009

275
Q

What is the process object in a Node.js program?

A

It is a global object that provides information about, and control over, the current process

276
Q

How do you access the process object in a Node.js program?

A
  • You can access it using the require(‘process’); function and assigning it to a variable or logging it to the console
  • Because it is global you can just access it with the process name
277
Q

What is the data type of process.argv in Node.js?

A

An array of strings

278
Q

What is a JavaScript module?

A

A JavaScript module is a section of a program, a small section of a larger database. It is a JavaScript file in this context.

279
Q

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, __dirname

280
Q

Give two examples of truly global variables in a Node.js program.

A

Console and process

281
Q

What is the purpose of module.exports in a Node.js module?

A

To be able to use data in one module in another module

282
Q

How do you import functionality into a Node.js module from another Node.js module?

A

You use require to import the functionality

283
Q

What is the JavaScript Event Loop?

A

It is responsible for taking callbacks from the past view and then pushing them to the stack when the stack is clear

284
Q

What is different between “blocking” and “non-blocking” with respect to how code is executed?

A
  • Blocking code is currently running on the call stack
  • Non-blocking code is an operation that is off of the call stack
285
Q

What is a directory?

A

A special kind of file that lists other files

286
Q

What is a relative file path?

A

The path to go from one directory to another file

287
Q

What is an absolute file path?

A

The path to a file form the root directory

288
Q

What module does Node.js include for manipulating the file system?

A

fs module

289
Q

What method is available in the Node.js fs module for writing data to a file?

A

The writeFile method

290
Q

Are file operations using the fs module synchronous or asynchronous?

A

Yes
- Base versions are asynchronous but Sync versions are synchronous

291
Q

What is NPM?

A

NPM is a software registry where open source developers can borrow and share packages of code. There are three primary components:
- The Website
- The Registry
- The CLI

292
Q

What is a package?

A

A package is a directory with at least one file and a package.json file

293
Q

How can you create a package.json with npm?

A

With the npm init command

294
Q

What is a dependency and how do you add one to a package?

A
  • A dependency is third-party code that is required at runtime (generally a package)
  • You can add a dependency with the npm install command
295
Q

What happens when you add a dependency to a package with npm?

A
  • It creates a module folder with the required package
  • It updates the package.json file to require the dependencies
296
Q

How do you add express to your package dependencies?

A

npm install express or just npm i express

297
Q

What Express application method starts the server and binds it to a network PORT?

A

The listen() method

298
Q

How do you mount a middleware to an Express application?

A

By using the use method or the HTTP request method as a method of the app object

299
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

Request object and response object

300
Q

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

application/json; charset=utf-8

301
Q

What is the significance of an HTTP request’s method?

A
  • It tells the server what type of request a client is making
  • It allows us as the programmer to determine what response to send the client
302
Q

What does the express.json() middleware do and when would you need it?

A
  • It parses the json body of incoming requests
  • We would need to mount it to our server if we are expecting clients to send json to the server
303
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a relational database. It is cited as the most advanced open-source and free relational database available. MySQL, SQL Server by Microsoft, and Oracle are some alternative relational databases.

304
Q

What are some advantages of learning a relational database?

A

Most developers work with relational databases a little bit and many other relational databases work off the same SQL language.

305
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

306
Q

What is a database schema?

A

A collection of tables. It defines how the data in a relational database should be organized.

307
Q

What is a table?

A

Data stored in ‘relations’

308
Q

What is a row?

A

A row is collection of attributes or a single record in a table

309
Q

What is SQL and how is it different from languages like JavaScript?

A

SQL is a declarative language like HTML and CSS whereas JavaScript is an imperative language. With SQL, we describe the results we want and the environment figures out how to provide us with the result

310
Q

How do you retrieve specific columns from a database table?

A

You use select followed by the column names in double quotes (separated by a comma if multiple)

311
Q

How do you filter rows based on some specific criteria?

A

You can use where “row” and an assignment operator like =, <, >, or != and the value. If the value is a string use single quotes

312
Q

What are the benefits of formatting your SQL?

A

It is more consistent and easier to read/understand

313
Q

What are four comparison operators that can be used in a where clause?

A

=, <, >. !=

314
Q

How do you limit the number of rows returned in a result set?

A

Use the limit keyword and the maximum number of rows you want returned

315
Q

How do you retrieve all columns from a database table?

A

You can use the universal selector (*) after the select keyword
e.g. select *

316
Q

How do you control the sort order of a result set?

A

A result set returns in ascending order by default. If you want it to be returned in descending order you would use the order by keywords, the column name in double quotes, followed by the desc keyword
e.g. order by “price” desc

317
Q

How do you add a row to a SQL table?

A

insert into

318
Q

What is a tuple?

A

A list of values being added to a SQL table

319
Q

How do you add multiple rows to a SQL table at once?

A

You separate each set of values with a ,
- Recommended to put on new lines for clarity

320
Q

How do you get back the row being inserted into a table without a separate select statement?

A

Use a returning statement

321
Q

How do you update rows in a database table?

A

With the update from keywords

322
Q

Why is it important to include a where clause in your update statements?

A

If you do not then it will update all of the items in a table

323
Q

How do you delete rows from a database table?

A

With the delete from keywords

324
Q

How do you accidentally delete all rows from a table?

A

Similar to update from, if you do not specify where then you can run into the issue of deleting everything

325
Q

What is a foreign key?

A

The shared data value between tables

326
Q

How do you join two SQL tables?

A

You first select the items you want to use from each table
Select which table you want as the base with from
Then using the join keyword and using keyword followed by the foreign key in parenthesis (can also have more items separated by a comma))

327
Q

How do you temporarily rename columns or tables in a SQL statement?

A

You can alias them using the as keyword

328
Q

What are some examples of aggregate functions?

A

Max, min, sum, count

329
Q

What is the purpose of a group by clause?

A

To separate groups by rows so that we can perform aggregate functions on them

330
Q

What are the three states a Promise can be in?

A

Pending - initial state - neither fulfilled or rejected
Fulfilled - operation was completed successfully
Rejected - operation has failed

331
Q

How do you handle the fulfillment of a Promise?

A

You can use the .then method on a promise to handle the fulfillment

332
Q

How do you handle the rejection of a Promise?

A

You can use the .catch method on a promise to handle the rejection

333
Q

What is Array.prototype.filter useful for?

A

It is useful for getting specific data out of arrays that you would want to use elsewhere

334
Q

What is Array.prototype.map useful for?

A

Map is useful for apply changes to all items in an array