Quiz Questions Flashcards

1
Q

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

A

In the head element.

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

Where do you put visible content about the HTML document?

A

In the body element.

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

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

A

Inside the HTML element. head goes first 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

First thing on the HTML doc, it declares which type of HTML the webpage 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 tags.

A

<p>, <a>, <span>, , <div></div></span></a></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

They provide additional information about the element, either editing it or adding more details.

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

& = & or &, < = < or

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

They take up the whole width of the page. Must start on new line.

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

They take up as much width as needed, like the span element.

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

Height is a high as the parent, width is the entire page.

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

both are as much as what the parent element size is.

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 are ordered using numbers, unordered list use bullet points or other characters to list

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

It is a block level 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

The ‘anchor’ tag, <a></a>

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

What is an absolute URL?

A

URL that points to a specific system and to a specific part

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

What is a relative URL?

A

URL that is 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

by using the ‘..’ notation followed by ‘/’, to go out of the current file you are in.

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

by naming the child directory followed by ‘/’.

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

like indicating the parent but with ‘../../’ notations.

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

Simply using the file/directory name.

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

The form element is the place where form controls should be placed in. The area/place where interactive controls are entered.

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, button, select, textarea

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 elements.

A

‘text’, ‘password’, ‘radio’

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

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

A

They are inline elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the names of the individual pieces of a CSS rule?
The rule set and declaration block
26
In CSS, how do you select elements by their class attribute?
Using the period or dot notation followed by the name
27
In CSS, how do you select elements by their type?
Using the name of the tag or type. i.e p, body, h1 etc.
28
In CSS, how do you select an element by its id attribute?
Using the # before the name of the id
29
Name three different types of values you can use to specify colors in CSS.
The RGB, Hex code, color name, also there is HSL(hue, saturation, lightness)
30
What CSS properties make up the box model?
Margin, border, padding, content
31
Which CSS property pushes boxes away from each other?
The margin
32
Which CSS property add space between a box's content and its border?
The padding
33
What is a pseudo-class?
It is a special keyword we can apply to CSS selectors
34
What are CSS pseudo-classes useful for?
Gives the selector a certain functionality or certain action depending on the pseudo class.
35
Name at least two units of type size in CSS.
Pixels (px), em, rem, percentage. 16px is 1rem and is usually default.
36
What CSS property controls the font used for the text inside an element?
The font-family
37
What are the four components of "the Cascade".
Source order, Inheritance, Specificity, !important
38
What does the term "source order" mean with respect to CSS?
The ruleset or selector put last takes precedence.
39
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance provides that functionality.
40
List the three selector types in order of increasing specificity.
1. Type selectors (h1, body, p, and pseudo elements) 2. Class selectors (.example, attribute selectors) 3. ID selectors (#example).
41
Why is using !important considered bad practice?
Makes debugging difficult and overall considered bad practice.
42
What is the default flex-direction of a flex container?
A row.
43
What is the default flex-wrap of a flex container?
No wrap which is a row, all in one line
44
Why do two div elements "vertically stack" on one another by default?
Because they are block level elements
45
What is the default value for the position property of HTML elements?
Static or normal flow
46
How does setting position: relative on an element affect document flow?
It does not affect the document flow.
47
How does setting position: relative on an element affect where it appears on the page?
It does not affect where it appears, unless we use offset properties to move them.
48
How does setting position: absolute on an element affect document flow?
It removes it from the document flow.
49
How does setting position: absolute on an element affect where it appears on the page?
Yes, it will move it relative to the closest parent depending on where it was originally.
50
How do you constrain an absolutely positioned element to a containing block?
By setting the containing block or parent element to position other than static.
51
What are the four box offset properties?
Top, bottom, right, left.
52
What is the purpose of variables?
To store data
53
How do you declare a variable?
Using the assignment operator '=' with 'var', 'const' and 'let'
54
How do you initialize (assign a value to) a variable?
The assignment operator '='.
55
What characters are allowed in variable names?
$, _ , any character. Can not start with numbers but can use numbers in.
56
What does it mean to say that variable names are "case sensitive"?
Can have two variables with the same spelling but different, coolname is not the same as coolName.
57
What is the purpose of a string?
To use text
58
What is the purpose of a number?
For calculations needed in the program
59
What is the purpose of a boolean?
Y or N answers or True or False.
60
What does the = operator mean in JavaScript?
To assign stuff
61
How do you update the value of a variable?
Use the variable name and assignment operator to a different value.
62
What is the difference between null and undefined?
Null is an intentional lack of value, undefined is a value that was never assigned.
63
Why is it a good habit to include "labels" when you log values to the browser console?
To better clarify when debugging.
64
Give five examples of JavaScript primitives.
Strings, Booleans, Numbers, null, undefined
65
What data type is returned by an arithmetic operation?
A number
66
What is string concatenation?
Combines strings together
67
What purpose(s) does the + plus operator serve in JavaScript?
Addition of number data types and concatenation of strings.
68
What data type is returned by comparing two values (, ===, etc)?
A boolean.
69
What does the += "plus-equals" operator do?
Adds the value and updates the variable.
70
What are objects used for?
Group together variables and functions to create a model. Used to model real world objects as well.
71
What are object properties?
They are called keys, they are variables attached to an object.
72
Describe object literal notation.
Listing out the key and value pair inside the curly brace
73
How do you remove a property from an object?
Using the delete operator and accessing the property in the object
74
What are the two ways to get or update the value of a property?
Dot notation or bracket notation.
75
What are arrays used for?
Storing a list of data in order
76
Describe array literal notation.
Using and listing out each property inside brackets
77
How are arrays different from "plain" objects?
Arrays are numerically indexed in the order they are listed.
78
What number represents the first index of an array?
Index of 0.
79
What is the length property of an array?
The total number of items in the array.
80
How do you calculate the last index of an array?
Length - 1.
81
What is a function in JavaScript?
They do things in the program, perform some sort of action or calculation.
82
Describe the parts of a function definition.
Function keyword, function (optional) name, the (optional) parameters, the code block, end of the code block.
83
Describe the parts of a function call.
Function name with passing arguments in place of the parameters.
84
When comparing them side-by-side, what are the differences between a function call and a function definition?
To call a function we simply write out the function name with () and arguments if needed
85
What is the difference between a parameter and an argument?
Parameters are placeholders when defining the function, arguments are the values we are placing in the parameter to run the function with.
86
Why are function parameters useful?
It is a variable local to the function. Allows us to pass arguments to it.
87
What two effects does a return statement have on the behavior of a function?
It outputs a value from the function and also stops the code block from running any further.
88
Why do we log things to the console?
To check if the code is working.
89
What is a method?
A function which is attached to an object.
90
How is a method different from any other function?
Method is just associated to an object.
91
How do you remove the last element from an array?
Use the .pop() method.
92
How do you round a number down to the nearest integer?
Using the Math.floor() method.
93
How do you generate a random number?
Using the Math.random() method.
94
How do you delete an element from an array?
Using the splice(), shift() or pop() method.
95
How do you append an element to an array?
Using the push() method.
96
How do you break a string up into an array?
Using the .split() method.
97
Do string methods change the original string? How would you check if you weren't sure?
No, you can check using the console.log.
98
Roughly how many string methods are there according to the MDN Web docs?
Mid thirties.
99
Is the return value of a function or method useful in every situation?
No, things like pop or shift arent as useful
100
Roughly how many array methods are there according to the MDN Web docs?
30 plus
101
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
102
Give 6 examples of comparison operators.
, >=, <=, ==, ===
103
What data type do comparison expressions evaluate to?
Boolean
104
What is the purpose of an if statement?
To check if a condition is true or false.
105
Is else required in order to use an if statement?
No, it is not required.
106
Describe the syntax (structure) of an if statement.
if (.....) { | }
107
What are the three logical operators?
&& (and), || (or), ! (not)
108
How do you compare two different expressions in the same condition?
&& or ||
109
What is the purpose of a loop?
To run block of code a certain amount of times or until a condition is met.
110
What is the purpose of a condition expression in a loop?
Checks the condition if it is true whether to run or not
111
What does "iteration" mean in the context of loops?
The process of the loop looping
112
When does the condition expression of a while loop get evaluated?
Before the code is run and at the end of each iteration.
113
When does the initialization expression of a for loop get evaluated?
At the start of the loop.
114
When does the condition expression of a for loop get evaluated?
Before each iteration.
115
When does the final expression of a for loop get evaluated?
At the end of each iteration.
116
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
'break', will not exit the function but will stop the loop from running.
117
What does the ++ increment operator do?
increases it by 1.
118
How do you iterate through the keys of an object?
a 'for in' loop and looking for the variable.
119
Why do we log things to the console?
Verify what code is doing, debugging etc
120
What is a "model"?
a representation of something
121
Which "document" is being referred to in the phrase Document Object Model?
The document node
122
What is the word "object" referring to in the phrase Document Object Model?
The collection of objects in javascript
123
What is a DOM Tree?
The model of the HTML contents on the browser
124
Give two examples of document methods that retrieve a single element from the DOM.
querySelector(), getElementById()
125
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll(), getElementsByClassName()
126
Why might you want to assign the return value of a DOM query to a variable?
When using it more than once, basically to save time
127
What console method allows you to inspect the properties of a DOM element object?
console.dir()
128
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
We want everything to load properly first before implementing the JS
129
What does document.querySelector() take as its argument and what does it return?
HTML elements, CSS selectors and returns the first one it encounters
130
What does document.querySelectorAll() take as its argument and what does it return?
HTML elements, CSS selectors and returns a node list
131
Why do we log things to the console?
debugging, and checking what is being output
132
Are all possible parameters required to use a JavaScript method or function?
false
133
What method of element objects lets you set up a function to be called when a specific type of event occurs?
the addeventlistener
134
What is a callback function?
A function definition getting passed inside the argument of another function
135
What object is passed into an event listener callback when the event fires?
The event object.
136
What is the event.target? If you weren't sure, how would you check? Where could you get more information about it?
The element which triggers the event,
137
What is the difference between these two snippets of code? element. addEventListener('click', handleClick) element. addEventListener('click', handleClick())
1st is the call back function, | 2nd we are calling the function as the argument.
138
What is the difference between these two snippets of code? element. addEventListener('click', handleClick) element. addEventListener('click', handleClick())
1st is the call back function where we give the event listener the handleClick functionality, 2nd we are calling the return value of the handleClick function as the argument.
139
What is the className property of element objects?
Allows to access or set the value of the class for that object element.
140
How do you update the CSS class attribute of an element using JavaScript?
Using the className property. element.className = new name
141
What is the textContent property of element objects?
Allows to update the text content of the element you are working with.
142
How do you update the text within an element using JavaScript?
Using the textcontent method. element.textContent = 'new content'
143
Is the event parameter of an event listener callback always useful?
No, not always needed function (event)
144
Would this assignment be simpler or more complicated if we didn't use a variable to keep track of the number of clicks?
More complicated, would make code longer and complicated.
145
Why is storing information about a program in variables better than only storing it in the DOM?
Want to create continuity and reliability.
146
What does the transform property do?
Allows to modify an element on the screen.
147
Give four examples of CSS transform functions.
Rotate, scale, skew, translate
148
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, transition-delay.
149
What event is fired when a user places their cursor in a form control?
The focus event.
150
What event is fired when a user's cursor leaves a form control?
The blur event.
151
What event is fired as a user changes the value of a form control?
The input event.
152
What event is fired when a user clicks the "submit" button within a ?
The submit event.
153
What does the event.preventDefault() method do?
It cancels the event if it is cancellable, it is preventing the page from refreshing.
154
What does submitting a form without event.preventDefault() do?
It dumps the form, reloading the page.
155
What property of a form element object contains all of the form's controls.
The elements property
156
What property of a form control object gets and sets its value?
The value property.
157
What is one risk of writing a lot of code without checking to see if it works so far?
Just good practice and saves time to check as you go and if the functionality is working.
158
What is an advantage of having your console open when writing a JavaScript program?
Check your script as you go and checking error messages.
159
Give two examples of media features that you can query in an @media rule.
Min-width, max-width, height, etc.
160
Which HTML meta tag is used in mobile-responsive web pages?
161
Does the document.createElement() method insert a new element into the page?
No it does not, until it appendChild()
162
How do you add an element as a child to another element?
using the appendChild()
163
What do you pass as the arguments to the element.setAttribute() method?
the Name and Value
164
What steps do you need to take in order to insert a new element into the page?
Create element and append, add any values if needed class, content etc.
165
What is the textContent property of an element object for?
So that we can add text and also get the text content. Getter and setter.
166
Name two ways to set the class attribute of a DOM element.
setAttribute('class', 'class name'), or the className property
167
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
1 is that, allows to pass in values. 2 it fulfills separation of concerns.
168
What is the event.target?
The point of interaction, whatever element is being interacted with
169
Why is it possible to listen for events on one element that actually happen its descendent elements?
event bubbling
170
What DOM element property tells you what type of element it is?
event.target.tagName
171
What does the element.closest() method take as its argument and what does it return?
Takes selectors, returns either itself or the matching ancestor, if nothing returns null
172
How can you remove an element from the DOM?
remove()
173
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?
Take advantage of bubbling, setting on parent.
174
What is the event.target?
The point of interaction, whatever element is being interacted with. The element of which the event took place.
175
What is the affect of setting an element to display: none?
It hides the element from the document. It removes it from the flow of the document.
176
What does the element.matches() method take as an argument and what does it return?
It takes an selector string and returns a boolean.
177
How can you retrieve the value of an element's attribute?
getAttribute() method
178
At what steps of the solution would it be helpful to log things to the console?
To check the value you are trying to return or change. Do it always basically.
179
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?
Would be difficult, alot more code. weird question.
180
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?
Would have to use a bunch of conditional statements.
181
What is a breakpoint in responsive Web design?
The point at which a media query is introduced.
182
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?
Percentages are relatively based on the screen or browser window the user has. Percentages will stay 'fixed' with their container whatever the size of the container. Pixels are absolute units that give us less flexibility.
183
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?
It will 'win' because it is the last rule or rule that comes latest. The latest rule is stronger or takes precedence.