Quiz Questions Flashcards

1
Q

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

A

. It’s about the meta information
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

The body tag of the HTML document

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 tag will usually go right after the tag and before the tag. The tag will go after the 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

The purpose is to tell a browser which version of HTML the page is using

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

, <li>, <ul>, ,
</ul></li>

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

Provides additional information about the contents of an element

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 >

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

Makes certain elements start on a new line in the browser window

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

Makes it appear to continue on the same line as their neighboring elements

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

Expands to a width of 100% of its parent container and the height would be according to the height of the 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

The height and width of the 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

Ordered: numbered
Unordered: bullet point

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

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

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

What is an absolute URL?

A

Linking to a different website / a full web address for the site

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

What is a relative URL?

A

When linking to other pages within the same site

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

use ../ to indicate the folder above the current one, then follow it with the file name
example: <a>Home</a>

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

use the name of the child folder, followed by a forward slash, then the file name
example: <a></a>

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

A

just use the file name (nothing else is needed)
example: <a>Reviews</a>

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 sibling directory?

A

use ../ to indicate the folder above the current one, then with a forward slash, write the sibling folder, then write the file name
example: <a>Home</a>

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

repeat the ../ to indicate that you want to go up two folders (rather than one), then follow it with the file name
example: <a>Home</a>

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

What is the purpose of an HTML form element?

A

collect data from users

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

Give five examples of form control elements.

A

text input
password input
radio buttons
checkboxes
dropdown boxes

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

Give three examples of type attribute values for HTML elements.

A

type=”image” when you want to use an image for the submit button
type=”submit” used to send a form to the server
type=”file” creates a box that looks like a text input followed by a browse button to select a file from their cmp and upload it

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

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

A

inline block

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

What are the six primary HTML elements for creating tables?

A

table row tr
table data td
table heading th
table header thead
table body tbody
table footer tfoot

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

What purpose do the thead and tbody elements serve?

A

thead - headings of the table
tbody - body/data of the table

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

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

A

stock reports
train timetables
sports results

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

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

A

selector, declaration, property, value

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 class attribute?

A

period and class name
.class {
}

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 type?

A

match the element names
example: h1, h2, h3 {}

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

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

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

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

A

rgb, hex codes, color names

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

What CSS properties make up the box model?

A

border
margin
padding

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

What is a pseudo-class?

A

keyword added to a selector that specifies a special state of the selected elements

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

What are CSS pseudo-classes useful for?

A

lets you apply a style to an element, not only in relation to the actual content, but to external factors like position of mouse, history of the navigator, etc

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

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

A

pixels
percentages
ems

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

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

A

row

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

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

A

nowrap: all flex items will be on one line

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

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

A

because they’re block elements

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

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

A

row

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

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

A

static

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 document flow?

A

doesn’t affect the position of surround elements and they will stay in the position they would be in normal flow

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 where it appears on the page?

A

you could change the position of the element where it would otherwise have been in normal flow

it doesn’t inherently affect where it appears, but you can move it from the original position

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 document flow?

A

it affects the document flow, as the other elements would simply ignore the space it would have taken up

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 where it appears on the page?

A

does not necessarily affect where it appears on the page, but it can affect where it appears on the page

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

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

A

using a relative position

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

What are the four components of “the Cascade”.

A

source order
inheritance
specificity
!important

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

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

A

the order that your css rules are written in your spreadsheet

styling provided last in your spreadsheet is the one that will take effect

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

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

List the three selector types in order of increasing specificity.

A

ID - CLASS - VALUE

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

Why is using !important considered bad practice?

A

it has side effects that mess with specificity

VERY HARD TO OVERRIDE

reverses the cascade order of stylesheets

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

What is the purpose of variables?

A

a temporary storage for data types

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

How do you declare a variable?

A

specify the type, leave at least one space, then the name for the variable and end the line with a semicolon;

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

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

A

use an assignment operator after the variable keyword and name, then give it its value

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

What characters are allowed in variable names?

A

letter, $, underscore, numbers

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

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

A

there is a difference in identification of the variables using uppercase and using lowercase letters

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

What is the purpose of a string?

A

data type that is used to represent text

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

What is the purpose of a number?

A

data type that represents numbers

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

What is the purpose of a boolean?

A

data type that is used to create true/false statements

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

What does the = operator mean in JavaScript?

A

assignment operator
to perform operations on the variables and values (operands)

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

How do you update the value of a variable?

A

reassign the value of the variable
you don’t have to write the keyword var again

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

What is the difference between null and undefined?

A

undefined: primitive variable that has been declared but not defined yet / it is undefined

null: assigned nothing value / it is an object

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

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

A

helps you debug as well and gives context of what to expect in the console

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

Give five examples of JavaScript primitives.

A

string
number
boolean
undefined
null

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

What is string concatenation?

A

the combination of 2+ strings to form one string

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

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

A

concatenation (strings) and addition (numbers)

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

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

A

addition assignment operator
adds the value of the right operand to a variable and assigns the result to the variable

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

What are objects used for?

A

to group together a set of variables/functions to create of model of something you’d recognize from the real world

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

What are object properties?

A

variables set to the object

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

Describe object literal notation.

A

first define a variable and assign it a properties inside a curly brace
keys:value
then end it with a curly brace

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

How do you remove a property from an object?

A

delete key.value

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

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

A

dot notation method
hotel.name = ‘Park’;

square bracket method
hotel[‘name’] = ‘Park’;

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

What are arrays used for?

A

stores a list of values

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

Describe array literal notation.

A

var colors;
colors = [‘white’, ‘black’, ‘custom’];

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

How are arrays different from “plain” objects?

A

in an object, the order of the properties is not important
however, in an array, the index numbers dictate the order of the properties

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

What is the length property of an array?

A

holds the number of items in the array

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

How do you calculate the last index of an array?

A

subtracting 1 from the length of an array gives the last index of an array

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

What is a function in JavaScript?

A

a set of statements that performs a task or calculates a value

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

Describe the parts of a function definition.

A

function keyword to start
optional name
comma separated list of 0+ parameters
start of a function’s code block
optional return statement
end of the function’s code block shown by }

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

Describe the parts of a function call.

A

function’s name
comma separated list of 0+ arguments surrounded by ()

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

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

A

if there is a code block, it’s a function definition, if not it’s a function call

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

What is the difference between a parameter and an argument?

A

parameter is a placeholder
argument is actual value

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

Why are function parameters useful?

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

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

A

makes functions more reusable and flexible

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

Why do we log things to the console?

A

to debug our code
validate our assumptions about how something works

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

What is a method?

A

function which is a property of an object

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

How is a method different from any other function?

A

a method is associated with an object, while a function is not

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

How do you remove the last element from an array?

A

pop() method

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

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

A

Math.floor() method

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

How do you generate a random number?

A

Math.random() method

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

How do you delete an element from an array?

A

splice() method
pop() method
shift() method

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

How do you append an element to an array?

A

push() method
unshift () method
splice() method

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

How do you break a string up into an array?

A

string.split() method

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

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

A

it does not mutate the original string

you can assign a variable to the original string and check it at the end

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

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

A

60-70 methods

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

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

A

no, it’s only useful when you need the function/method to return something
ex: pop(), shift() method

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

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

A

around 40 methods (?)

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

Give 6 examples of comparison operators.

A

== equal to
=== strict equal to
=! not equal to
==! strict not equal to
> greater than
< less th an

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

What is the purpose of an if statement?

A

to check if a condition is true or false

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

Is else required in order to use an if statement?

A

a code block to execute if the value is true

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

Describe the syntax (structure) of an if statement.

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

What are the three logical operators?

A

logical &&
logical ||
logical !

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

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

A

logical &&
logical ||

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

What is the purpose of a loop?

A

to repeat a portion of code a set number of times until the desired process is complete

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

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

A

tells how many times the loop should continue running until the counter reaches a certain number

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

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

A

each time the code runs

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

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

A

before executing the statement again

once before the initialization

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

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

A

occurs one time only before the loop begins

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

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

A

each time before the loop runs

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

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

A

at the end of each loop iteration

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

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

What does the ++ increment operator do?

A

increment the value of a variable by 1 and reassigning it

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

How do you iterate through the keys of an object?

A

Using the for in statement.

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

Why do we log things to the console?

A

it’s a feature for debugging purposes

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

What is a “model”?

A

general def: representation

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

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

A

the document node in the DOM tree (webpage)

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

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

A

the nodes in the dom tree

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

What is a DOM Tree?

A

model of the webpage

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

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

A

getElementsByClassName(‘class’)

getElementsByTagName(‘tagName’)

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

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

A

to store the location of the element in a variable

saves the browser looking through the DOM tree to find the same element again

caches the selection

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

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

A

if you place the script tag on top, it’ll load up the main.js and run the dom, making the webpage take longer to load and slow down the pg rendering speed

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

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

A

takes a string containing one or more selector and returns
the element object representing the first element in the doc that matches the argument

returns null if it doesn’t find anything

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

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

A

argument: selectors
returns: all of those elements that match the selector in a node list

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

Why do we log things to the console?

A

to debug
to see what our code is doing

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

What is the purpose of events and event handling?

A

`we want to get events to trigger some sort of JS code

allows our page to be more interactive

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

What is a callback function?

A

function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action

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

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

A

the event object

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

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

A

target property of the event object

point of interaction on the dom

the object that dispatches the event

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

What is the difference between these two snippets of code?

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

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

What is the className property of element objects?

A

`

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

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

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

What is the textContent property of element objects?

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

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

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

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

A

No

149
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

150
Q

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

A
151
Q

What does the transform property do?

A

CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.

152
Q

The transition property is shorthand for which four CSS properties?

A

transition delay, transition timing function

153
Q

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

A

focus()

154
Q

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

A

blur()

155
Q

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

A

change

156
Q

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

A

submit

157
Q

What does the event.preventDefault() method do?

A

prevents the default behavior

158
Q

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

A

it will reload the page

159
Q

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

A

elements property

160
Q

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

A

value attribute

use object.value

161
Q

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

A

you won’t know which parts don’t work

162
Q

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

A
163
Q

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

A

no, it is not yet part of the dom tree until it is appended

164
Q

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

A

you can use append child

165
Q

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

A

the element you would want to be appended or made a child\

element, value

166
Q

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

A
  1. createElement()
  2. optionally, you setAttribute() and createTextNode()
  3. appendChild() to add it to the page
167
Q

What is the textContent property of an element object for?

A

The text content of the element and all descendaces, with spacing and CSS hidden text, but without tags

168
Q

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

A

setAttribute()
className property

169
Q

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

A

we’re able to call the function more than once

170
Q

What is the event.target?

A

gets the element on which the event originally occurred

171
Q

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

A

due to event capturing?

172
Q

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

A

tagName

173
Q

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

A

it takes the css selector you want to match the element and its ancestors against

returns the first ancestor of the selected element

174
Q

How can you remove an element from the DOM?

A

remove()

175
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

adding an event listener to the parent element

176
Q

What is the event.target?

A

event that is being targeted

element interacted with

the element that dispatches the event

177
Q

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

A

the affected element will disappear and will not take up space in the web page

178
Q

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

A

argument: takes in a css selector

returns: true if the element matches the selectors, otherwise false

179
Q

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

A

getAttribute()

180
Q

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

A
181
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

add addeventlistener for each element

182
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

display none and display show? with buttons?

183
Q

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

A
184
Q

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

A

meta name=”viewport”

185
Q

What is a breakpoint in responsive Web design?

A

the point at which a website’s content and design will adapt in a certain way in order to provide the best possible user experience

186
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

you don’t know the pixel count for every screen so it makes everything relative to the screen

columns are boxes so they can negotiate between those breakpoints and maintain their shape and boxes

187
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 the css rules for the smaller min-width was written after

rules at the end of the style sheet take precedence over the front rules

188
Q

What is JSON?

A

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

189
Q

What are serialization and deserialization?

A

process of converting an Object into stream of bytes so that it can be transferred over a network or stored in a persistent storage

reverse process: turning a stream of bytes into an object in memory

190
Q

Why are serialization and deserialization useful?

A

Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization

191
Q

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

A

using the JSON.stringify() method

192
Q

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

A

usign the JSON.parse() method

193
Q

How do you store data in localStorage?

A

setItem()

194
Q

How do you retrieve data from localStorage?

A

getItem()

195
Q

What data type can localStorage save in the browser?

A

string data

196
Q

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

A
197
Q

What is a method?

A

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
199
Q

Describe method definition syntax (structure).

A

keyword function with function name and with (parameter) open curly brace for the code block with whatever you want it to execute then close curly brace

200
Q

Describe method call syntax (structure).

A

function object of a property with an argument in the parenthesis`

201
Q

How is a method different from any other function?

A

method is associated with an object, while a function is not

202
Q

What is the defining characteristic of Object-Oriented Programming?

A

objects can contain both data (as properties) and behavior (as methods)

203
Q

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

A

abstraction
encapsulation
inheritance
polymorphism

204
Q

What is “abstraction”?

A

being able to work 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

give programmers a way to interact with a system in a simplified, consistent fashion

207
Q

What is this in JavaScript?

A

an implicit parameter of all JavaScript functions

208
Q

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

A

it is available in a function’s code block even though it was never included in the function’s parameter list or declared with var

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?

var character = {
firstName: ‘Mario’,
greet: function () {
var message = ‘It's-a-me, ‘ + this.firstName + ‘!’;
console.log(message);
}
};

A

object character

211
Q

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

character.greet();

A

It’s a me Mario!
we are calling the greet method of the character object.

212
Q

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

var hello = character.greet;
hello();

A

It’s a me, undefined because var hello does not have a value stored for the firstName property

213
Q

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

A

we would not know from the definition!

214
Q

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

A

“the object to the left of the dot” when the function is called (as a method).

215
Q

What kind of inheritance does the JavaScript programming language use?

A

prototype-based inheritance

216
Q

What is a prototype in JavaScript?

A

original model on which something is patterned

217
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

because they are prototyped onto it

218
Q

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

A

proto

219
Q

What does the new operator do?

A

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

220
Q

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

A

prototype property

221
Q

What does the instanceof operator do?

A

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

222
Q

What is a “callback” function?

A

function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action

223
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() function

224
Q

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

A

setInterval()

225
Q

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

A

0 or immediately

226
Q

What do setTimeout() and setInterval() return?

A

The returned timeoutID is a positive integer value which identifies the timer created by the call to setTimeout(). This value can be passed to clearTimeout() to cancel the timeout.

The returned intervalID is a numeric, non-zero value which identifies the timer created by the call to setInterval(); this value can be passed to clearInterval() to cancel the interval.

227
Q

What is a client?

A

service requesters

program that’s capable

228
Q

What is a server?

A

providers of a resource or service

provides whatever the request is

229
Q

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

A

GET request

230
Q

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

A

HTTP method - describing what action to be performed
request target - usually a URL or the absolute path of the protocol, port, and domain are usually characterized by the request context
HTTP version - defines the structure of the remaining message, acting as an indicator of the expected version to use for the `response

231
Q

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

A
  1. The protocol version, usually HTTP/1.1.
  2. A status code, indicating success or failure of the request. Common status codes are 200, 404, or 302
  3. A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.
232
Q

What are HTTP headers?

A

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

consists of its case-insensitive name followed by a colon, then by its value

meta information

allows us to get or put information about the request

233
Q

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

A

NO, responses with a status code that sufficiently answer the request without the need for corresponding payload usually don’t

234
Q

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

A

MDN

235
Q

What is AJAX?

A

technique for loading data into part of a pg without having to refr3esh the entire pg

236
Q

What does the AJAX acronym stand for?

A

asynchronous javascript and xml

237
Q

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

A

XMLHttpRequest object

238
Q

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

A

‘load’`

239
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

prototypical inheritance

240
Q

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

A

statements to be executed

241
Q

What does block scope mean?

A

restricts the variable that is declared inside a specific block, from access by the outside of the block

242
Q

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

A

block scope

243
Q

What is the difference between let and const?

A

let can be reassigned while const cannot

244
Q

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

A

we are adding new elements to the array, but we are not reassigning the array

245
Q

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

A

if you know that the value won’t/can’t be reassigned, use const

if you know that the value will/can be reassigned, use let, esp for loops or mathematical algorithms where the value is changing

246
Q

What is the syntax for writing a template literal?

A

uses backticks and use a backslash if the string contains a backtick
\n for new liens

interpolation: ${ }

247
Q

What is “string interpolation”?

A

the ability to transform a string so that it is safe to include in HTML

248
Q

What is destructuring, conceptually?

A

to dismantle something

to unpack values from arrays or properties from objects into distinct variables

249
Q

What is the syntax for Object destructuring?

A

const or let { property1: variable1, property2: variable2 } = object;

250
Q

What is the syntax for Array destructuring?

A

let [x, y, z] = array;

251
Q

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

A

the assignment is after the curly braces for creating,
for destructuring, writing the actual value is not required

252
Q

What is the syntax for defining an arrow function?

A

=>

253
Q

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

A

it implicitly returns

254
Q

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

A

arrow function captures the this value of the enclosing context instead of creating its own this context

uses it from the enclosing lexical scope

255
Q

What is a CLI?

A

command-line interfaces

256
Q

What is a GUI?

A

graphical user interface
aimed for users of the technology, not the producers

257
Q

Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp

A

man - interface to the system reference manuals
cat - to concatenate files to standard output
ls - list directory contents
pwd - print name of current/working directory (print working directory)
echo - display a line of text
touch - change file timestamps
mkdir - make directories
mv - move (rename) files
rm - remove files or directories
cp - copy files and directories

258
Q

What are the three virtues of a great programmer?

A

laziness, hubris, impatience

259
Q

What is Node.js?

A

program that allows JavaScript to be run outside of a web browser

environment that allows us to execute Javascript code without a browser

260
Q

What can Node.js be used for?

A

used to build back ends for web applications, command-line programs, or any kind of automation that developers wish to perform

261
Q

What is a REPL?

A

read-eval-print loop

takes single user inputs, executes them, and returns the result to the user

262
Q

When was Node.js created?

A

may 27 2009

263
Q

What back end languages have you heard of?

A

Ruby, Python, Java

264
Q

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

A

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

object that has a lot of info about node js

265
Q

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

A

using require()

globally available

266
Q

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

A

array

267
Q

What is a JavaScript module?

A

single .js file

268
Q

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

A

filename dirname

269
Q

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

A

dirname filename
console
process object

270
Q

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

A

instructions that allow us to export from a given file so that other files are allowed to access the exported code

271
Q

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

A

require()

272
Q

What is the JavaScript Event Loop?

A

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

273
Q

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

A

blocking is executed synchronously
non-blocking is executed asynchronously

274
Q

What is a directory?

A

file system cataloging structure

275
Q

What is a relative file path?

A

the path related to the present working directly(pwd)

276
Q

What is a absolute file path?

A

always contains the root element and the complete directory list required to locate the file

277
Q

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

A

file system module
fs module

278
Q

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

A

writefile method

279
Q

Are file operations using the fs module synchronous or asynchronous?`

A

asynchronous

280
Q

What is NPM?

A

world’s largest software registry

281
Q

What is a package?

A

directory with one or more files in it

282
Q

How can you create a package.json with npm?

A

use the npm init command

283
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

284
Q

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

A

Install the dependencies to the local node_modules folder.

285
Q

How do you add express to your package dependencies?

A

npm install express

286
Q

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

A

listen method

287
Q

How do you mount a middleware with an Express application?

A

use method

288
Q

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

A

req - request object
res - response object
next - function that triggers the request to be sent to the next middleware
- lets us break our logic into multiple pieces

289
Q

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

A

application/json

290
Q

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

A

So we can indicate what the intent of the request method is

291
Q

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

A

parses incoming requests with JSON data and turns it into an object

to send JSON data to the server

292
Q

What is PostgreSQL and what are some alternative relational databases?

A

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

MySQL, SQL Server by Microsoft, Oracle by Oracle Corporation

293
Q

What are some advantages of learning a relational database?

A

they support good guarantees about data integrity
- They can store and modify data in a way that makes data corruption as unlikely as possible

294
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

295
Q

What is a database schema?

A

collection of tables
defines how the data in relational database should be organized
blueprint on how a database should look like

296
Q

What is a database schema?

A

collection of tables
defines how the data in relational database shoudl be organized

297
Q

What is a table?

A

list of rows each having the same set of attributes i.e. all students in a “students” table could have “firstName” “lastName” and “dateOfBirth”

298
Q

What is a row?

A

record in that spreadsheet

299
Q

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

A

SQL (structured Query Language) : primary way of interacting with relational databases

declarative programming language instead of JS which is an imperative language

300
Q

How do you retrieve specific columns from a database table?

A

select “”
from “”

301
Q

How do you filter rows based on some specific criteria?

A

select “”
from “”
where “” = ‘’

302
Q

What are the benefits of formatting your SQL?

A

consistent style and readability

303
Q

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

A

<, >, =, and !=

304
Q

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

A

limit integer

305
Q

How do you retrieve all columns from a database table?

A

select *

306
Q

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

A

order by “” desc/asc

307
Q

How do you add a row to a SQL table?

A

using the insert statement

308
Q

What is a tuple?

A

list of values

309
Q

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

A

separate the tuples by commas

310
Q

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

A

returning clause

311
Q

How do you update rows in a database table?

A

update statement
set

312
Q

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

A

it might update every row in the table!

313
Q

How do you delete rows from a database table?

A

delete statement
where clause

314
Q

How do you accidentally delete all rows from a table?

A

delete statement without stating a where clause

315
Q

What is a foreign key?

A

one column that links 2 tables together

316
Q

How do you join two SQL tables?

A

select statement
from clause
join clause
- join “blank” using (“foreign key”)`

317
Q

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

A

create an alias for it by using as
ex: select “products”.”name” as “product”,
“suppliers”.”name” as “supplier”

318
Q

What are some examples of aggregate functions?

A

max()
min()
avg()

319
Q

What is the purpose of a group by clause?

A

separate rows into groups and perform aggregate functions on those groups of rows

320
Q

What are the three states a Promise can be in?

A

pending
fulfilled
rejected

321
Q

How do you handle the fulfillment of a Promise?

A

using a .then method

322
Q

How do you handle the rejection of a Promise?

A

using a .catch method

323
Q

What is Array.prototype.filter useful for?

A

creates a shallow copy of a portion of a given array, filtered down to just the elements from the given array that pass the test implemented by the provided function

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

allows you to “reduce” an array to a single value

executes a user-supplied “reducer” callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value

326
Q

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier to read or to express

327
Q

What is the typeof an ES6 class?

A

function

328
Q

Describe ES6 class syntax.

A

declare a class with keyword class, name of class, then open curly braces
initialize the properties with constructor keyword and properties in parenthesis
open curly brace
this.properties = proeprties

329
Q

What is “refactoring”?

A

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

330
Q

What is Webpack?

A

a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts and stylesheets.

module bundler

331
Q

How do you add a devDependency to a package?

A

you install it using npm install

332
Q

What is an NPM script?

A

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

syntax is even mroe compact than CommonJS
structure can be statically analyzed (for static checking, optimization, etc.)
Their support for cyclic dependencies is better than CommonJS’s

335
Q

What kind of modules can Webpack support?

A

ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules

336
Q

What is React?

A

React is a JavaScript library for creating user interfaces.

337
Q

What is a React element?

A

an object representation of a DOM node

338
Q

How do you mount a React element to the DOM?

A

render()

339
Q

What is Babel?

A

toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments

takes newer syntax and converts into a widely used syntax

340
Q

What is a Plug-in?

A

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

341
Q

What is a Webpack loader?

A

transformations that are applied to the source code of a module

allow you to pre-process files as you import or “load” them

342
Q

How can you make Babel and Webpack work together?

A

incorporate the babel loader allows them work together

343
Q

What is JSX?

A

allows us to write HTML-like syntax in React
a syntax extension to JavaScript

344
Q

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

A

internally every JSX is creating a React Component using JSX transformer

345
Q

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

A

use the babel-loader and have

346
Q

What is a React component?

A

independent and reusable bits of code

function that takes in arbitrary inputs and returns JSX

347
Q

How do you define a function component in React?

A
  1. is a JavaScript/ES6 function.
  2. must return a React element (JSX)
  3. always starts with a capital letter (naming convention)
348
Q

How do you mount a component to the DOM?

A

render method

349
Q

What are props in React?

A

arguments passed into React components

props stands for properties

350
Q

How do you pass props to a component?

A

pass props with key value pair attributes

351
Q

How do you write JavaScript expressions in JSX?

A

You can put any valid JavaScript expression inside the curly braces in JSX

352
Q

How do you create “class” component in React?

A

class keyword
the component’s name must start with an upper case letter
needs “extends React.Component” creates an inheritance to React.Component, and gives your component access to React.Component’s functions
needs render()

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

states is for managing data and contains data or info about the component

355
Q

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

A

With JSX you pass a function as the event handler
using camelCase, rather than lowercase
inside curly braces

356
Q

What are controlled components?

A

An input form element whose value is controlled by React

357
Q

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

A

value
onChange

358
Q

What Array method is commonly used to create a list of React elements?

A

map method

359
Q

What is the best value to use as a “key” prop when rendering lists?

A

use a string that uniquely identifies a list item among its siblings

360
Q

What does the acronym LIFO mean?

A

last-in-first-out //
the last thing pushed onto the stack is the first thing that can be popped out

361
Q

What methods are available on a Stack data structure?

A

push()
pop()

362
Q

What must you do to access the value at an arbitrary point in a stack (not just the “top”)?

A

peek()

363
Q

what in javascript uses a stack

A

array?

364
Q

What does the acronym FIFO mean?

A

first-in-first-out (FIFO) operations: the first thing enqueued onto the queue is the first thing that can be dequeued out.

365
Q

What methods are available on a Queue data structure?

A

enqueue(value) - adds a value to the “back” of the queue
dequeue() - removes the “front” value from the queue and returns it
peek() - returns the “front” value of the queue without removing it.

366
Q

What must you do to access the value at an arbitrary point in a queue (not just the “front”)?

A

Dequeue until you reach desired value

367
Q

How are linked lists different from an array?

A

Linked lists are sequential access (like a queue), not random access (like an array)

368
Q

How would you access an arbitrary node in a linked list (not just the “head”)?

A

you have to start at the beginning, then jump from node to node until you get there