LFZ Module 1 Flashcards

1
Q

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

A

Inside the head tags. It is a container for metadata, which is data about the html document used by browsers, search engines, and other web services.

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

Inside the body tags.

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

Where do the head andbodytags go in a valid HTML document?

A

After the !DOCTYPE tag and inside the html tags. Head on top and then body.

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

What is the purpose of a!DOCTYPE declaration?

A

To tell a browser which version of HTML the page is using. It helps render a page correctly.

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

body, h1, head, ol, and p.

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 provide additional information about the element’s content. Specified in the start tag. Comes in name and value pairs (name=”value”).
Example: href, src and style.

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

Characters used in and reserved in HTML code.

Example: Ampersand (&amp)

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

Always starts on a new line in the browser.

Example: h1, p, ul, li

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

How do inline elements affect the document flow?

A

Inline elements always continue on the same line as their neighboring elements.
Example: a, b, em, img

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

Takes up the full width available of its parent element (container), and vertical space is the height of its contents.

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

Only takes up as much width as necessary bounded by the tags defining the element. Even if we set the width and height, it will only take up what is necessary for that 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 Lists (ol) are lists that are numbered in order.
Example: Steps for a recipe
Unordered Lists (ul) are lists that begin with a bullet point and not in a particular order.
Example: Ingredients for a recipe
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

Block Element, because each list item starts on a new line.

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

What HTML tag is used to link to another website?

A

The a (anchor) element.

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

What is an absolute URL (Uniform Resource Locator)?

A

It is the URL (web address) of the value for the href attribute when linking to other websites.

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

What is a relative URL (Uniform Resource Locator?

A

A shorthand to link to other pages on the same website. If all the pages are in the same folder, then the href value is the name of the file. No need to include domain name.
Example: href=”index.html”, href=”contact.html”

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

../

Example: ../index.html

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

Name of child folder followed by a forward slash then the file name.
Example: music/listings.html

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

../ ../ to go up two folders followed by the file name.

Example: ../../index.html

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

./
OR Just use the file name, nothing else.
Example: review.html

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

To collect information/user data from visitors to the site. Also, for searching, registering, shopping online, signing up newsletters or mailing lists.

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

”, , , and “

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

Give three examples oftypeattributes for HTML”“elements.

A

type=text, type=password and type=email

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

Is an HTMLelement a block element or an inline element?

A

Inline element, because it continues on the same line.

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: used to create a table, tr (table row): indicates the start of each row, td (table data): table cell, th (table heading): use scope attribute row/col, thead and tbody.

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

What purpose do thetheadandtbodyelements serve

A

thead: Defines a set of rows defining the head of the columns of the table. The headings of the table go in here.
tbody: Groups a set of table rows inside the body of an html table.

Semantic meaning
Divide the page up

It also helps people who use screen readers and allows you to style these sections in a different manner than the rest of the table.

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

Inventory management and to keep track of home finances.

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: indicates which element the rule applies to

Declaration: indicates how the elements referred to in the selector should be styled. Inside the declaration is the Property and Value.

Example: P {Font-family: Arial;}

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

A

Matches an element whose class attribute has a value that matches the one specified after the period (or full stop) symbol.

Example: .title { }

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

Matches element names.

Example: h2, h3, h3 { }

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

A

Matches an element whose id attribute has a value that matches the one specified after the hash symbol.

Example: #introduction { }

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

color - foreground color (text)
background-color
opacity - can specify the opacity of an element and any of its child elements. (value between 0.0-1.0)

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

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

Allows us to change the appearance of elements when a user is interacting with them.

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

:hover - When a user has a mouse over a button, you can use the hover pseudo-class to change the color of the button.

:active - Applied when an element is being activated by user. Example: when a link is being clicked, it will change color.

:focus - Applied when an element has focus. Example: when cursor is over a form input, it is ready to accept typing.

**order: :link, :visited, :hover, :focus, :active

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

Pixels (px) , Percentage (%) and ems (em).

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

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

No wrap. Items will all try to fit onto one line.

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

Because it is the default behavior of html block 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

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

What is thedefaultvalue for thepositionproperty of HTML elements?

A

Static - Appears on a new line one after the other, vertically down the page.

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

How does settingposition: relativeon an element affect document flow?

A

Moves element from normal flow position shifting it to the top right bottom or left

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

How does settingposition: relativeon an element affect where it appears on the page?

A

They stay in the in the position they would be in normal flow. Can modify its final position. Can make it over lap other elements. This does not effect the position of other elements.

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

How does settingposition: absoluteon an element affect document flow?

A

Positions the element in relation to tis containing element. Taken out of the normal flow.

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

How does settingposition: absoluteon an element affect where it appears on the page?

A

Does not affect the position of any surrounding elements. The other elements ignore the space it would have taken up.
An absolutely positioned element no longer exists in the normal document layout flow. Instead, it sits on its own layer separate from everything else.

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

Define the position property of ancestor.

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, right, bottom, left

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

What is the purpose of variables?

A

Where a script temporarily stores information to do its job. Represent values in your scripts that are likely to change

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

How do youdeclarea variable?

A

Var - keyword used to create a variable in js.

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

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

A

Must give it a name. (Identifier) should describe the kind of data the variable holds.

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

What characters are allowed in variable names?

A

It can contain letters, numbers, dollar sign ($), or an underscore (_). Note that you must not use a dash(-) or a period (.) in a variable name. Must begin with a letter $ or underscore.

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

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

A

Variable add and Add would be different variable names because the case is different.

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

What is the purpose of a string?

A

Consists of letters / characters. Strings can be used when working with any kind of text. They are frequently used to add new content into a page and they can contain HTML markup.

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

What is the purpose of a number?

A

The numeric data type handles numbers.

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

What is the purpose of a boolean?

A

Boolean data types can have one of two values: true or false.

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

What does the=operator mean in JavaScript?

A

Assigned to

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

How do you update the value of a variable?

A

Take the variable name and assign it to another value.

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

What is the difference betweennullandundefined?

A

Null was made to intentionally be empty like saving a parking spot that will be filled later. Undefined is when there is a variable assigned but no value.

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

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

A

Helps when debugging so you know what data you are dealing with.

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

Give five examples of JavaScript primitives.

A

Number, string, boolean, null, and undefined.

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

What data type is returned by an arithmetic operation?

A

Numeric

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

What is string concatenation?

A

The process of joining together two or more strings to create one new string.

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

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

A

Used to join the strings on either side of it.

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

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

A

Addition assignment 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
69
Q

What are objects used for?

A

To group together a set of variables and functions to create a model of something from the real world.

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

What are object properties?

A

In an object variables become known as properties. Tells us about the object and attached to the object.

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

Describe object literal notation.

A

Object is the curly braces and their contents stored in a variable. Properties come in key value pairs. Method is a formula inside of that object. Separate each property and method with a comma except last one.

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

How do you remove a property from an object?

A

Use the delete operator keyword followed by dot notation of the object name, member operator (.) and property name.

73
Q

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

A

By using dot notation or brackets.

hotel.rooms = 40

74
Q

What are arrays used for?

A

To store a list or a set of values that are related to each other. Helpful when you do not know how many items a list will contain.

75
Q

Describe array literal notation.

A

Create an array and give it
 a name just like you would any other variable (using the var keyword followed by the name of the array). The values are assigned to the array inside a pair of square brackets, and each value is separated by a comma.

76
Q

How are arrays different from “plain” objects?

A

The key for each value is its index number.

77
Q

What number represents the first index of an array?

A

0

78
Q

What is thelengthproperty of an array?

A

Tells how many items in the array.

79
Q

How do you calculate the last index of an array? Array name.

A

arrayname.length - 1

80
Q

What is a function in JavaScript?

A

It is a group of a series of statements that perform a specific task. It should take an input and return an output. Allows code to be packed up for reuse throughout a program. Block of code that can be reused over and over again.

81
Q

Describe the parts of a function definition.

A
  1. The function keyword begins the creation.
  2. Optional name follows it.
  3. A comma-separated list of 0 or more parameters inside ( ).
  4. { is the start of the function’s code block.
  5. Optional return statement.
  6. } end of function’s code block.
82
Q

Describe the parts of a function call.

A
  1. The function’s name.

2. A comma-separated list of 0 or more arguments inside ( ).

83
Q

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

A

Calling the function is shorter and easier to understand.

We only use the name and in paranthesis the arguments.

84
Q

What is the difference between a parameter and an argument?

A

We declare parameters when we define a function. Arguments are what we pass in when we call the function.

85
Q

Why are function parameters useful?

A

No limitations. It is like a placeholder. It is basically a variable whose value is not known until we call the function and pass an argument. When the function’s code block is run, the parameter will be holding the value of the argument.

86
Q

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

A
  1. Causes the function to produce a value we can use in our program.
  2. Prevents any more code in the function’s code block from being run.
87
Q

Why do we log things to the console?

A

It is a good tool for debugging purposes. It gives you the data to what is the data.

88
Q

What is a method?

A

It is a function which is a property of an object. There are two kinds: 1) instance methods: build in tasks performed by an object instance 2) static method: tasks that are called directly on an object constructor.

89
Q

How is a method different from any other function?

A

It is attached to or belongs to an object. Uses “this” keyword.

90
Q

How do you remove the last element from an array?

A

pop()

91
Q

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

A

Math.floor() generates between 0(inclusive)-1 (exclusive)

92
Q

How do you generate a random number?

A

Math.random()

93
Q

How do you delete an element from an array?

A

splice( ) first parameter: the index which to start. second parameter: delete count or if you want to add make it 0 followed by a third parameter which is what you want to add in the array.

94
Q

How do you append an element to an array?

A

.push( )

95
Q

How do you break a string up into an array?

A

.split( ) indicates the character which you want to split.

96
Q

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

A

All string methods return a new string. They don’t modify the original string.
You can check by console.log( ).

97
Q

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

A

36ish

98
Q

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

A

No, sometimes it is used to perform an outside function. For example, a function that opens up a box on the page.

99
Q

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

A

38ish

100
Q

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

A

MDN Mozilla Developers Network

101
Q

Give 6 examples of comparison operators.

A

> greater than, < less than, == equal to, != not equal to, ==== strict equal to, >= greater than or equal to, <= less than or equal to

102
Q

What data type do comparison expressions evaluate to?

A

Boolean / true or false

103
Q

What is the purpose of anifstatement?

A

To compare two variables or expressions to return true or false

104
Q

Iselserequired in order to use anifstatement?

A

No, unless you are adding additional conditional statements or if you want something for when a conditional is not met.

105
Q

Describe the syntax (structure) of anifstatement.

A

if (condition) {
code to execute if value is true;
}

if keyword, followed by a condition inside paranthesis(expression), opening curly brace, code to execute if value is true, closing curly brace.

106
Q

What are the three logical operators?

A

& logical and, || logical or, and ! logical not

107
Q

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

A

and / or logical operators

108
Q

What are the four components of “the Cascade”.

A

Source Order, Inheritance, Specificity & !Important.

109
Q

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

A

The order that your css rules are written in your stylesheet. The styling provided for an element last in your stylesheet is the styling that will ultimately take effect.

110
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 inheritance. For example: putting font-family on body will apply to most child elements. Borders and background colors are non-inherited properties. (All: revert;)

111
Q

List the three selector types in order of increasing specificity.

A

Type selectors (h1), class selectors (.example), ID selectors (#example).

112
Q

Why is using!importantconsidered bad practice?

A

Because it makes debugging more difficult by breaking the natural cascading in your stylesheets.

113
Q

What is the purpose of a loop?

A

Loops are used to perform repeated tasks based on a condition. It will continue until it returns false.

114
Q

What is the purpose of aconditionexpression in a loop?

A

Normally true and false. If value is true, loop statement executes. If it is false, loop terminates.

115
Q

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

A

The repetition. Each time the computer goes through a loop. Or a set of operations.

116
Q

Whendoes theconditionexpression of awhileloop get evaluated?

A

First. The condition test occurs before the statement in the loop is executed. If true, statement is executed.

117
Q

Whendoes theinitializationexpression of aforloop get evaluated?

A

Is only created the first time the loop is run before first execution.

118
Q

Whendoes theconditionexpression of aforloop get evaluated?

A

The first time after initialization and if true after each iteration it will be the first.

119
Q

Whendoes thefinalexpression of aforloop get evaluated?

A

Expression that is run after every iteration. Usually used to increment a counter. But it can be used to decrement a counter too.

120
Q

Besides areturnstatement, which exits its entire function block, which keyword exits a loop before itsconditionexpression evaluates tofalse?

A

break; terminates loop and goes onto the next statement of code.

121
Q

What does the++increment operator do?

A

Increases counter by one. Reassigns updated number to the variable.

122
Q

How do you iterate through the keys of an object?

A

For…in (for (var key in object) return key.

123
Q

Why do we log things to the console?

A
  • So you know what specific data you are working with.
124
Q

What is a “model”?

A

When browser loads web page it creates a model of the page in memory. Dom specifies the way the browser should structure this model. It is a representation of something.

125
Q

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

A

At the top of the tree is the document node. It represents the entire page.

126
Q

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

A

The document itself is an object. The nodes do not represent a data structure, they represent objects, which have functions and identity.

127
Q

What is a DOM Tree?

A

Shows the structure of the document. It is made of objects. Each object represents a different part of the page loaded in the browser stored on DOM node.

128
Q

Give two examples ofdocumentmethods that retrieve a single element from the DOM.

A

getElementById(), querySelector()

129
Q

Give one example of adocumentmethod that retrieves multiple elements from the DOM at once.

A

getElememtsByClassName()

130
Q

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

A

When you will be working with that element more than once. It is really storing the location of the elements with in the DOM tree in a variable. (Stores a reference to the object in the DOM tree.)

131
Q

Whatconsolemethod allows you to inspect the properties of a DOM element object?

A

console.dir()

132
Q

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

A

Because the browser needs to parse all of the elements in the HTML page before the javascript can access them.

133
Q

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

A

Uses CSS syntax and returns single method on the first of the matching elements.

134
Q

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

A

Uses css syntax to select one or more elements and returns all of those that match.

135
Q

Why do we log things to the console?

A

So we know what specific data we are working with.

136
Q

What is the purpose of events and event handling?

A

It can be used to trigger a certain function. To interact with users.

137
Q

What do[ ]square brackets mean in function and method syntax documentation?

A

Parameters (optional)

138
Q

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

A

Event Listeners

139
Q

What is a callback function?

A

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

140
Q

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

A

Event object

141
Q

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

A

It is the reference to the element that triggered the event.

142
Q

What is the difference between these two snippets of code?

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

A

element. addEventListener(‘click’, handleClick) - runs when event fired
. passing a function definition so it can call the function when it needs to.
element. addEventListener(‘click’, handleClick()) - runs when page loads

143
Q

What is theclassNameproperty of element objects?

A

Gets and sets the value of the class attribute of the specified element.

144
Q

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

A

element.className === ‘currentclassname’

Then set element.className = ‘newclassname’

145
Q

What is thetextContentproperty of element objects?

A

Grabs just the text in the containing element.

146
Q

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

A

Elementname.textcontent = ‘new classname’

147
Q

Is theeventparameter of an event listener callback always useful?

A

No, not always.

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 especially with the if statements.

149
Q

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

A

So we can reuse without declaring the variable again without querying the Dom again.
We have more control what is going on inside rather than the dom.

150
Q

What does the transform property do?

A

Rotate, scale, skew or translate an element. Modifies the coordinate space of the css.

151
Q

Give four examples of CSS transform functions.

A

Matric, translate, scale, rotate, skew, scale.

152
Q

Thetransitionproperty is shorthand for which four CSS properties?

A

transition-property,transition-duration,transition-timing-function, andtransition-delay.

153
Q

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

A

Focus event

154
Q

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

A

Blur event

155
Q

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

A

Change event

156
Q

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

A

Submit event

157
Q

What does theevent.preventDefault()method do?

A

prevents the default browser action of the element from occurring.

158
Q

What does submitting a form withoutevent.preventDefault()do?

A

It doesn’t save the forms values and it automatically reloads. The form is submitted automatically.

159
Q

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

A

form.elements

HTML FORM CONTROLS COLLECTION

160
Q

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

A

Method property

161
Q

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

A

You don’t know where the error is in the code.

162
Q

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

A

To see what data you are working and to catch errors early on.

163
Q

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

A

No, it is just creating an element node that is not yet part of the dom tree. You need to appendChild() to an element on the dom.

164
Q

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

A

Parent.appendChild(child).

165
Q

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

A

(Name, value)

166
Q

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

A

createElement(), createTextNode(), att text node to element, appendChild() to dom element

167
Q

What is thetextContentproperty of an element object for?

A

To get/set text content of an element.

168
Q

Name two ways to set theclassattribute of a DOM element.

A

setAttribute(‘class’, ‘className’) , .className

169
Q

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

A
  1. It gets automated, no matter how many objects you pass in

2. And can reuse it again on different data sets you pass in

170
Q

What is theevent.target?

A

Returns the element that triggered the event or interacted with. (Current target is the element that is listening).

171
Q

What is the affect of setting an element todisplay: none?

A

The element is not visible on the page and does not take up space on page. Property visibility set to none will not display but still take up space on the page.

172
Q

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

A

Checks to see if the element is the selector. Takes in a string as a parameter returns a result boolean true or false or syntax-err if the specified selector string is invalid.

173
Q

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

A

Element.getAttribute();

174
Q

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

A

All the time.

175
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

You would have to put an event listener on each tab.

176
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 have to check each one individually if it matches manually writing out each conditional statement.

177
Q

What is abreakpointin responsive Web design?

A

Breakpoints allow the layout to change at predefined points. It is the point where the website content adjusts according to user screen size. When @medica rules become active.

178
Q

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

A

Pixel density can vary, so we use % because they are more flexible and are relative to to the screen or viewport.

179
Q

If you introduce CSS rules for a smallermin-widthafterthe styles for a largermin-widthin your style sheet, the CSS rules for thesmallermin-widthwill “win”. Why is that?

A

If two media queries collide with each other the last rule is applied.