Quiz Questions Flashcards

1
Q

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

A

In the header 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

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

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

A

The header element goes below the html tag, and the body goes below the header tag.

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

What is the purpose of a declaration?

A

Instruction to the browser on which version of HTML the page is written in

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

Give five examples of HTML element tags.

A
  1. h1
  2. p
  3. div
  4. body
  5. html
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

Attributes control an elements behavior

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

® &

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

Take up all the width available
Starts on a new line
Has a top and bottom margin by default

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

Only takes up as much width as necessary

Does not start on a new line

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

The width is the entirety of the available space on the page

The height is the height of whatever content is in the element

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

The default width and height are based on the content that reside in the element

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 uses numbers to form a list that has a specific order while an unordered list uses bullet points and does not have a specific order to the elements

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

They are block elements

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

an a element tag

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

What is an absolute URL?

A

Uses a http or https and links to an outside website

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

What is a relative URL?

A

Links to a page within the same directory

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

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

A

../ (Parent directory)

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

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

A

/ (folder) / (child directory)

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 grand parent directory?

A

../../(Grandparent directory)

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 the same directory?

A

./(same directory)

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

What is the purpose of an HTML form element?

A

Collect data from a user or visitor of your site

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

Give five examples of form control elements.

A
input
label
select
text area 
button
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

Give three examples of type attributes for HTML input elements.

A

radio
email
text

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

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

A

Inline

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

What are the six primary HTML elements for creating tables?

A
table
thead
tbody
tr
th
td
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

What purpose do the thead and tbody elements serve?

A

To specify which elements are in the header and body of the table created

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

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

A

Class grades

Schedules

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

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

A
Selector
Declaration block
Declaration
Property 
Value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

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

A

.class {

}

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

In CSS, how do you select elements by their type?

A

type {

}

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

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

A
#id {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

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

A

Hexadecimal
Keywords
RGB
(also HSL)

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

What CSS properties make up the box model?

A

Content
Margin
Padding
Border

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

Which CSS property pushes boxes away from each other?

A

Margin

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

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

A

Padding

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

What is a pseudo-class?

A

Keyword added to a selector to specify a specific state

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

What are CSS pseudo-classes useful for?

A

Helps add style when certain actions are performed by user (i.e. hover, focus)

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

Name at least two units of type size in CSS.

A

px, em, pt, %

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

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

A

font-family

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

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

A

row (left-to-right)

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

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

A

nowrap

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

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

A

They are block level elements

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

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

A

row (left-to-right)

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

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

A

Static, normal flow

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

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

A

It does not

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

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

A

Does not change unless you have offset properties

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

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

A

Removed from document flow

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

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

A

It will reposition to top left of parent that is non-static unless it is contained

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

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

A

Make sure parent is non-static

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

What are the four box offset properties?

A

top, bottom, left, right

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

What are the four components of “the Cascade”.

A

Source Order, Inheritance, Specificity and !important

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

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

A

the order in which css rule sets are in your style sheet will define their specificity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
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

by inheriting the properties from all the parent elements

inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
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
55
Q

Why is using !important considered bad practice?

A

It makes debugging hard and breaks the natural cascading in style sheets

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

What is the purpose of variables?

A

Store data

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

How do you declare a variable?

A

using var before a name for the variable

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

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

A

using the = operator and adding a value after it with a semicolon at the end

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

What characters are allowed in variable names?

A

letter, underscores, dollar signs, numbers but cannot start with a number and cannot contain spaces

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

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

A

The capitalization of variable names matters and must be typed with consistent capitalization

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

What is the purpose of a string?

A

To store text or characters within a variable

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

What is the purpose of a number?

A

To store numerical data within a variable

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

What is the purpose of a boolean?

A

To store a value of true or false to a variable to create true/false statements

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

What does the = operator mean in JavaScript?

A

Means a value is assigned to a variable

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

How do you update the value of a variable?

A

Reassign a value to it

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

What is the difference between null and undefined?

A

Null is an object while undefined is a type

Undefined means no value is set to it yet, where as null is intentional absence

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

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

A

Makes debugging your code easier and checking your results

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

Give five examples of JavaScript primitives.

A

Boolean, Null, Undefined, String, Number

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

What data type is returned by an arithmetic operation?

A

number

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

What is string concatenation?

A

combines two or more strings together

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

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

A

for arithmetic or string concatenation

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

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

A

boolean

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

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

A

adds the value on the right, to the variable on the left, and then assigns that value back into the variable on the left

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

What are objects used for?

A

Objects group together a set of variables and functions to create a model
of a something you would recognize from the real world

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

What are object properties?

A

Storing information

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

Describe object literal notation.

A

The object is the curly braces and their contents

Each key is separated from its value by a colon

Separate each property and method with a comma

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

How do you remove a property from an object?

A

using the delete operator

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

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

A

dot notation and bracket notation

hotel.name = ‘Park’;
or
hotel[‘name] = ‘Park’;

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

What are arrays used for?

A

Creating a list of values that are related to each other.

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

Describe array literal notation.

A

var (variable name) = []

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

How are arrays different from “plain” objects?

A

They use index numbers as keys

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

What number represents the first index of an array?

A

0

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

What is the length property of an array?

A

the number of values in an array

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

How do you calculate the last index of an array?

A

the length of an array minus 1

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

What is a function in JavaScript?

A

a set of statements that takes an input and performs a task or calculates a value as an output

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

Describe the parts of a function definition.

A
function functionName(parameters) {
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

Describe the parts of a function call.

A

functionName(arguments);

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

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

A

function call doesn’t need the word function before it, defn does

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

What is the difference between a parameter and an argument?

A

a parameter is in the function definition, where an argument is the value passed in the function when called

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

Why are function parameters useful?

A

Allow passing of information in the function

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

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

A

Ends the function

Returns a value to the calling function

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

Why do we log things to the console?

A

To check that we are getting the correct results

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

What is a method?

A

A function that is the property of an object

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

How is a method different from any other function?

A

Regular functions aren’t associated with objects, methods are

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

How do you remove the last element from an array?

A

.pop()

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

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

A

Math.floor()

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

How do you generate a random number?

A

Math.random()

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

How do you delete an element from an array?

A

.splice()

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

How do you append an element to an array?

A

.push()

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

How do you break a string up into an array?

A

.split()

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

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

A

They do not. You can check by using console.log()

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

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

A

40 ish

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

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

A

No

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

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

A

30 ish

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
105
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
106
Q

Give 6 examples of comparison operators.

A

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

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

What data type do comparison expressions evaluate to?

A

Boolean

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

What is the purpose of an if statement?

A

Making logical comparisons

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

Is else required in order to use an if statement?

A

Else is optional

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

Describe the syntax (structure) of an if statement.

A

if (condition) {
instruction;
}

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

What are the three logical operators?

A

&&, ||, !

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

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

A

Using logical operators

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

What is the purpose of a loop?

A

Repeating through code multiple times until we tell it to stop

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

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

A

To tell the computer to keep looping that coding or to stop based on value of true or false

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

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

A

How many times to go through the loop

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

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

A

Before each pass through of the loop

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

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

A

One time before the first loop begins

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

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

A

Once before every iteration

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

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

A

end of each for loop

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

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

A

break

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

What does the ++ increment operator do?

A

Increase value of a variable by 1

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

How do you iterate through the keys of an object?

A

using a for in loops of the object and pushing the key values of that object

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

Why do we log things to the console?

A

To check that our results are accurate, makes debugging issues easier

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

What is a “model”?

A

the DOM tree, or the model of the web page

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

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

A

all the elements and information in the HTML

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

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

A

Each node represents an object in the document

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

What is a DOM Tree?

A

The document model containing document nodes, element nodes, attribute nodes and text nodes.

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

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

A

getElementById()

querySelector()

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

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

A

getElementsByClassName()

querySelectorAll()

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

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

A

In case we need to access a particular node in the DOM

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

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

A

Console.dir()

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

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

A

The browser needs to parse all of the elements in the HTML page before the JavaScript code can access them.

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

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

A

A CSS selector and returns the first element in the document with that selector

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

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

A

A CSS selector and returns a node list of the document’s elements that match the specified selectors

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

Why do we log things to the console?

A

To make sure that we are getting the expected results

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

What is the purpose of events and event handling?

A

to execute code based on an event that happens to an element

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

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

A

No

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

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

A

addEventListener()

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

What is a callback function?

A

A function passed in another function as an argument

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

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

A

The function which we want to execute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
141
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 element that triggered the event. By checking the console and MDN

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

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

element.addEventListener(‘click’, handleClick())

A

One calls a function and one is a definition

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

What is the className property of element objects?

A

sets the value of the class attribute of the specified element

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

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

A

elementNodeReference.className =

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

What is the textContent property of element objects?

A

the text content of the node and its descendants

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

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

A

elementNodeReference.textContent =
or
innerHTML

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

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

A

No

148
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

More complicated

149
Q

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

A

Easier to maintain code and you can track it much easier

150
Q

What does the transform property do?

A

lets you rotate, scale, skew, or translate an element

151
Q

Give four examples of CSS transform functions.

A

rotate, scale, skew, translate

152
Q

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

A

focus

153
Q

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

A

blur

154
Q

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

A

input

155
Q

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

A

submit

156
Q

What does the event.preventDefault() method do?

A

prevents the default action from happening

i.e. page reloading on submit

157
Q

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

A

reloads the page and pushes form to url

158
Q

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

A

elements

159
Q

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

A

value

160
Q

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

A

Makes debugging harder, more code to look through

161
Q

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

A

You can see errors as they happen

162
Q

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

A

No, just creates the elements until we append to existing element

163
Q

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

A

append.Child()

164
Q

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

A

name, value

165
Q

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

A

Create element
Create text node
Add text node to element
Add element to DOM

166
Q

What is the textContent property of an element object for?

A

sets text content for a specific node

167
Q

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

A

.className

setAttribute()

168
Q

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

A

its reusable and dynamically creates

169
Q

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

A

width
height
color

170
Q

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

A

viewport meta tag

171
Q

What is the event.target?

A

Reference to where the event was fired

172
Q

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

A

Because events bubble up

173
Q

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

A

tagName

174
Q

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

A

takes a css selector and retuns the element that is closest to the target

175
Q

How can you remove an element from the DOM?

A

remove()

176
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

add the listener to the parent

177
Q

What is the event.target?

A

the target of the event being fired

178
Q

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

A

does not show up on the screen

179
Q

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

A

css selector as an argument and checks if the selector matches the element

180
Q

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

A

getAttribute()

181
Q

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

A

all the time

182
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

It would act independently from other tabs

183
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

You wouldnt be able to check each element

184
Q

The transition property is shorthand for which four CSS properties?

A

transition-delay
transition-duration
transition-property
transition-timing-function

185
Q

What is JSON?

A

common data interchange format used to send and store information in computer systems

186
Q

What are serialization and deserialization?

A

Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network

Deserialization is the reverse process: turning a stream of bytes into an object in memory.

187
Q

Why are serialization and deserialization useful?

A

Allow us to transfer data between different computer systems

188
Q

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

A

JSON.stringify()

189
Q

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

A

JSON.parse()

190
Q

How to you store data in localStorage?

A

localStorage.setItem()

191
Q

How to you retrieve data from localStorage?

A

localStorage.getItem()

192
Q

What data type can localStorage save in the browser?

A

string data

193
Q

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

A

when they are about to be unloaded

194
Q

What is a breakpoint in responsive Web design?

A

Defined pixel value in which when the screen reaches a point, a transformation happens, where media queries are introduced

195
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

Dynamically adapts as the screen changes

196
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

CSS source order

media query below another one has less precedence

197
Q

What is a method?

A

A method is a function which is a property of an object.

198
Q

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

A

Definition is inside an object as a property with a function value, call is objectName.methodName

199
Q

Describe method definition syntax (structure).

A

property name: function

200
Q

Describe method call syntax (structure).

A

objectName.methodName()

201
Q

How is a method different from any other function?

A

Associated with an object

202
Q

What is the defining characteristic of Object-Oriented Programming?

A

It has to do with grouping similar functions and values in objects (Encapsulation)

203
Q

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

A

Abstraction, Inheritance, Encapsulation, Polymorphism

204
Q

What is “abstraction”?

A

Working with complex things in simple ways

205
Q

What does API stand for?

A

Application programming interface

206
Q

What is the purpose of an API?

A

Allows applications to talk to eachother

207
Q

What is this in JavaScript?

A

Refers to the object it belongs to

208
Q

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

A

Is the object of the method it belongs to

209
Q

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

A

call time

210
Q

What does this refer to in the following code snippet?

A

the object character

211
Q

Given the above character object, what is the result of the following code snippet? Why?

A

It’s-a-me, Mario!

this.firstName = Mario

212
Q

Given the above character object, what is the result of the following code snippet? Why?

A

It’s-a-me, undefined!

Function is called, but this is no longer part of the character object, therefore doesnt exist

213
Q

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

A

The property

214
Q

What kind of inheritance does the JavaScript programming language use?

A

prototypal

215
Q

What is a prototype in JavaScript?

A

the mechanism by which JavaScript objects inherit features from one another

216
Q

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

A

They are inherited

217
Q

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

A

prototype

218
Q

What does the new operator do?

A

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

219
Q

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

A

prototype

__proto__

220
Q

What does the instanceof operator do?

A

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

221
Q

What is a “callback” function?

A

a function passed into another function as an argument

222
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

setTimeout()

223
Q

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

A

setInterval()

224
Q

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

A

0 seconds

225
Q

What do setTimeout() and setInterval() return?

A

an identifying value you can use later when you need to clear the interval

226
Q

What is a client?

A

a piece of computer hardware or software that accesses a service made available by a server

227
Q

What is a server?

A

a piece of computer hardware or software (computer program) that provides functionality for other programs or devices

228
Q

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

A

GET

229
Q

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

A

HTTP Method, Request Target, HTTP Version

230
Q

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

A

Protocol version, status code, status text

231
Q

What are HTTP headers?

A

let the client and the server pass additional information with an HTTP request or response

232
Q

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

A

MDN

233
Q

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

A

No

234
Q

What is Ajax?

A

technique for loading data into part of a page without having to refresh entire page

235
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

236
Q

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

A

XMLHttpRequest

237
Q

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

A

load

238
Q

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

A

prototypal inheritance

239
Q

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

A

Code within curly braces

Function, if statement

240
Q

What does block scope mean?

A

Within curly braces, variables defined within are only available there

241
Q

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

A

Block

242
Q

What is the difference between let and const?

A

const cannot be reassigned, let can

243
Q

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

A

We can change values but not reassign them

244
Q

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

A

Depends on if the value is going to be reassigned or not

245
Q

What is the syntax for writing a template literal?

A

wrapping string in backticks

${var} to substitute

246
Q

What is “string interpolation”?

A

substituting allows embedded values and expressions into string

247
Q

What is destructuring, conceptually?

A

provides an alternative way to assign properties of an object to variables

248
Q

What is the syntax for Object destructuring?

A

let { firstName: fname, lastName: lname } = person;

249
Q

What is the syntax for Array destructuring?

A

let [x, y, z] = getScores();

250
Q

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

A

Curly vs square brackets

251
Q

What is the syntax for defining an arrow function?

A

let add = (x, y) => x + y;

252
Q

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

A

do not need to specify return

253
Q

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

A

this inside an arrow function is equivalent to the global object

254
Q

What is a CLI?

A

a command line program that accepts text input to execute operating system functions

255
Q

What is a GUI?

A

type of user interface through which users interact with electronic devices via visual indicator representations

256
Q

What are the three virtues of a great programmer?

A

laziness, impatience, hubris

257
Q

What is Node.js?

A

an asynchronous event-driven JavaScript runtime

258
Q

What can Node.js be used for?

A

build scalable network applications

259
Q

What is a REPL?

A

a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user

260
Q

When was Node.js created?

A

2009

261
Q

What back end languages have you heard of?

A

Python
PHP
C++

262
Q

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

30+

263
Q

Why should a full stack Web developer know that computer processes exist?

A

Having an understanding of processes helps know whats going on when

264
Q

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

A

a global that provides information about, and control over, the current Node.js process

265
Q

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

A

process

266
Q

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

A

Just use it or use require(‘process’)

267
Q

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

A

Array

268
Q

What is a JavaScript module?

A

A file

269
Q

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

A

exports, require, module, __filename, and __dirname

270
Q

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

A

global

setInterval

271
Q

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

A

specify what in that file are able to be used in another file it is called

272
Q

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

A

require() and then use its return value

273
Q

What is the JavaScript Event Loop?

A

a constantly running process that monitors both the callback queue and the call stack

274
Q

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

A

Blocking methods execute synchronously and non-blocking methods execute asynchronously

275
Q

What is a directory?

A

Collection of files

276
Q

What is a relative file path?

A

refers to a location that is relative to a current directory

277
Q

What is an absolute file path?

A

full path, starts with the root element and ends with the other subdirectories

278
Q

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

A

fs

279
Q

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

A

writeFile()

280
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

281
Q

What is NPM?

A

package manager for the JavaScript programming language

282
Q

What is a package?

A

a directory with one or more files in it

reusable, self containing code

283
Q

How can you create a package.json with npm?

A

npm init –yes

284
Q

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

A

another package that your package needs in order to work

npm install (package name)

285
Q

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

A

will add all the dependencies that the dependency has as all

286
Q

How do you add express to your package dependencies?

A

npm install express –save

287
Q

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

A

listen()

288
Q

How do you mount a middleware with an Express application?

A

const app = express();

app.use(function (req, res, next) {
console.log(‘Time:’, Date.now());
next();
});

289
Q

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

A

request and response

290
Q

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

A

application/json

291
Q

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

A

indicate the desired action to be performed for a given resource

292
Q

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

A

deal with the (incoming) data (object) in the body of the request

293
Q

What is PostgreSQL and what are some alternative relational databases?

A

a powerful, free, open source Relational Database Management System (RDBMS)

alternatives: MySQL, SQL Server, Oracle

294
Q

What are some advantages of learning a relational database?

A

support good guarantees about data integrity

can store and modify data in a way that makes data corruption as unlikely as possible

arguably the most widely used kind of database

295
Q

What is one way to see if PostgreSQL is running?

A

top command

296
Q

What is a database schema?

A

A collection of tables, describes the table

297
Q

What is a table?

A

all data stored in relations

298
Q

What is a row?

A

record of the data

299
Q

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

A

SQL is a declarative programming language

JavaScript is imperative where you basically tell the JavaScript runtime what to do and how to do it

300
Q

How do you retrieve specific columns from a database table?

A

a select statement

example:

select “name”,
“price”
from “products”;

301
Q

How do you filter rows based on some specific criteria?

A

using a where clause

302
Q

What are the benefits of formatting your SQL?

A

enhance readability and keep consistent styling

303
Q

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

A

, =, !=

304
Q

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

A

limit at end of statement

305
Q

How do you retrieve all columns from a database table?

A

*

306
Q

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

A

order by

307
Q

How do you add a row to a SQL table?

A

insert into “table” (“ “)

values (‘ ‘)

308
Q

What is a tuple?

A

a list of values

309
Q

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

A

enter the values on a new line

310
Q

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

A

returning *;

311
Q

How do you update rows in a database table?

A

update “table nam”
set “header” = 100
where “header” = 24;

312
Q

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

A

to target a specific row

313
Q

How do you delete rows from a database table?

A

delete from “table”
where “column header” = 24
returning *;

314
Q

How do you accidentally delete all rows from a table?

A

Not specifying what row you want to delete

315
Q

What is a foreign key?

A

set of attributes in a table that refers to the primary key of another table

316
Q

How do you join two SQL tables?

A

example:
select *
from “products”
join “suppliers” using (“supplierId”);

317
Q

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

A

Example:

“products”.”name” as “product”

318
Q

What are some examples of aggregate functions?

A

sum() avg() count()

319
Q

What is the purpose of a group by clause?

A

used to group rows that have the same values

320
Q

What are the three states a Promise can be in?

A

pending, fufilled, rejected

321
Q

How do you handle the fulfillment of a Promise?

A

promiseObject.then(value) => {}

322
Q

How do you handle the rejection of a Promise?

A

promiseObject.catch(error) => {}

323
Q

What is Array.prototype.filter useful for?

A

filtering an array to get specific results

324
Q

What is Array.prototype.map useful for?

A

creates a new array populated with the results of calling a provided function on every element in the calling array

325
Q

What is Array.prototype.reduce useful for?

A

return a calculation from an array

326
Q

What is “syntactic sugar”?

A

designed to make things easier to read or to express

327
Q

What is the typeof an ES6 class?

A

returns a string indicating the type of the unevaluated operand

328
Q

Describe ES6 class syntax.

A

template for creating objects that encapsulate data with code to work on that data

ex:
class Rectangle {
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
}
329
Q

What is “refactoring”?

A

restructuring existing computer code—changing the factoring—without changing its external behavior

330
Q

What is Webpack?

A

bundle JavaScript files for usage in a browser

331
Q

How do you add a devDependency to a package?

A

–save-dev

332
Q

What is an NPM script?

A

convenient way to bundle common shell commands for your project

333
Q

How do you execute Webpack with npm run?

A

npm run build

334
Q

How are ES Modules different from CommonJS modules?

A

pre-parsed in order to resolve further imports before code is executed, using import from or export

335
Q

What kind of modules can Webpack support?

A

ES6 modules. CommonJS modules. AMD modules

336
Q

What is React?

A

JavaScript library that is used for building user interfaces

337
Q

What is a React element?

A

an object that virtually describes the DOM nodes that a component represents

338
Q

How do you mount a React element to the DOM?

A

ReactDOM.render(element, container[, callback])

339
Q

What is Babel?

A

used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers

340
Q

What is a Plug-in?

A

a software component that adds a specific feature to an existing computer program

341
Q

What is a Webpack loader?

A

node-based utilities built for webpack to help webpack to compile and/or transform a given type of resource that can be bundled as a javascript module

342
Q

How can you make Babel and Webpack work together?

A

use a babel loader

343
Q

What is JSX?

A

JSX is an extension to the JavaScript language syntax which provides a way to structure component rendering using syntax familiar to many developers. It is similar in appearance to HTML

344
Q

Why must the React object be imported when authoring JSX in a module?

A

Because JSX is syntactic sugar for react create element

345
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

load the transform react jsx plugin

346
Q

What is a React component?

A

independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML

347
Q

How do you define a function component in React?

A
function Welcome(props) {
  return <h1>Hello,{props.name</h1>;
}
348
Q

How do you mount a component to the DOM?

A

ReactDOM.render()

349
Q

What are props in React?

A

arguments passed into React components

350
Q

How do you pass props to a component?

A

function parameter

351
Q

How do you write JavaScript expressions in JSX?

A

surround the JavaScript code in { } brackets

352
Q

How do you create “class” component in React?

A

you need to extend React.Component

353
Q

How do you access props in a class component?

A

this.props

354
Q

What is the purpose of state in React?

A

represent an information about the component’s current situation

355
Q

How to you pass an event handler to a React element?

A

onClick={function}

instead of onClick = “function()”

356
Q

What are controlled components?

A

a component that renders form elements and controls them by keeping the form data in the component’s state

357
Q

What two props must you pass to an input for it to be “controlled”?

A

value

onChange()

358
Q

What does express.static() return?

A

An object

359
Q

What is the local __dirname variable in a Node.js module?

A

tells you the absolute path of the directory containing the currently executing file

360
Q

What does the join() method of Node’s path module do?

A

all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path

361
Q

What does fetch() return?

A

returns the data of the format JSON or XML. This method returns a promise

362
Q

What is the default request method used by fetch()?

A

.then()

363
Q

How do you specify the request method (GET, POST, etc.) when calling fetch?

A

specify a method: (POST, etc)

364
Q

When does React call a component’s componentDidMount method?

A

After the component is mounted to the DOM

365
Q

Name three React.Component lifecycle methods.

A

componentWillUnmount(),
componentDidUpdate(),
componentDidMount()

366
Q

How do you pass data to a child component?

A

using the props