Quiz Questions Flashcards
Where do you put non-visible content about the HTML document?
on the “head” tag
Where do you put visible content about the HTML document?
on the “body” tag
Where do the “head” and “body” tags go in a valid HTML document?
between the “HTML” tags.
What is the purpose of a “DOCTYPE!” declaration?
for the browsers to know which type of HTML it is.
Give five examples of HTML element tags.
h1,h2,h3,p,span,head,body etc
What is the purpose of HTML attributes?
to give extra information about the HTML
Give an example of an HTML entity (escape character).
less than or greater than
How do block-level elements affect the document flow?
they take up the whole space/appear on the new line
How do inline elements affect the document flow?
they only take as much as they need/continue on the same line
What are the default width and height of a block-level element?
width: 100%
height: as much as needed
What are the default width and height of an inline element?
whatever is needed.
What is the difference between an ordered list and an unordered list in HTML?
Ordered list comes with numbering while unordered list comes with bullet point.
Is an HTML list a block element or an inline element?
it is a block element.
What HTML tag is used to link to another website?
“a” tag
What is an absolute URL?
actual location to the site
What is a relative URL?
relative path to the source. for instance, a source located on the same server but on a different level.
How do you indicate the relative link to a parent directory?
add “../” (go up one directory to parent)
How do you indicate the relative link to a child directory?
go directly in. just input the file name
How do you indicate the relative link to a grand parent directory?
add “../../”
How do you indicate the relative link to the same directory?
type the final file name
What is the purpose of an HTML form element?
group inputs together and utilization of the data. (collecting data)
Give five examples of form control elements.
adding text, choosing option, submitting form, uploading files, drop down
Give three examples of type attributes for HTML “input” elements.
password,text,radio
Is an HTML “input” element a block element or an inline element?
Inline
What are the six primary HTML elements for creating tables?
table, tr, td, th, thead, tbody, tfoot
What purpose do the thead and tbody elements serve?
allows us to style in different method, easier for people using screen reader.
Give two examples of data that would lend itself well to being displayed in a table.
schedules, tabular data
What are the names of the individual pieces of a CSS rule?
selector, declaration block
In CSS, how do you select elements by their class attribute?
adding a “.”
In CSS, how do you select elements by their type?
name itself
In CSS, how do you select an element by its id attribute?
add an hastag (you dont really wanna use id for css styling)
what are the three ways to specify color in CSS?
hex, rgb, built in value
What CSS properties make up the box model?
border, margin, padding
Which CSS property pushes boxes away from each other?
margin.
Which CSS property add space between a box’s content and its border?
padding.
What is a pseudo-class?
keyword added to a selector that specifies a special state of the selected element
What are CSS pseudo-classes useful for?
give added functionality.
more customization
Name at least two units of type size in CSS.
pixels, percentage,(r)em
What CSS property controls the font used for the text inside an element?
font-family
What is the default flex-direction of a flex container?
horizontal (row)
What is the default flex-wrap of a flex container?
no wrap
What is the default value for the position property of HTML elements?
static
How does setting position: relative on an element affect document flow?
no effect on doc flow
How does setting position: relative on an element affect where it appears on the page?
relative to where it would be (based on original place)
How does setting position: absolute on an element affect document flow?
moves it from the doc page
How does setting position: absolute on an element affect where it appears on the page?
attaches to the parents position
How do you constrain an absolutely positioned element to a containing block?
make the container non-static
What are the four box offset properties?
top bottom left right.
What is the purpose of variables?
to store information
How do you declare a variable?
var (name of var) = “”
How do you initialize (assign a value to) a variable?
assignment operator “= “
What characters are allowed in variable names?
_ , $ no numerals at the beginning / no space
What is the purpose of a number?
determining the values
What is the purpose of a boolean?
to determine which script should run.
What does the = operator mean in JavaScript?
equal. setting the value
How do you update the value of a variable?
set a new valuee
What does the = operator mean in JavaScript?
equal. setting the value / assignment operator
How do you update the value of a variable?
set a new value
What is the difference between null and undefined?
null: invalid object/ intentional empty value
undefined: no argument (type undefined) / unintentional no value.
Why is it a good habit to include “labels” when you log values to the browser console?
easy to go thru
What data type is returned by an arithmetic operation?
number
What is string concatenation?
adding two strings together
What purpose(s) does the + plus operator serve in JavaScript?
addition, concatenation
What data type is returned by comparing two values (, ===, etc)?
boolean value
What does the += “plus-equals” operator do?
x+=y ->
x = x+y
What are objects used for?
to model real life object
What are object properties?
variables within the object
Describe object literal notation.
var (name) = {
properties : value }
How do you remove a property from an object?
use delete operator
What are the two ways to get or update the value of a property?
. or []
What are arrays used for?
to store list of data
Describe array literal notation.
[ ]
How are arrays different from “plain” objects?
they have orders
What number represents the first index of an array?
0
What is the length property of an array?
measures the length of the array
How do you calculate the last index of an array?
array.length -1
What is a function in JavaScript?
object that can be called and execute the code block.
Describe the parts of a function definition.
function + name of the function + (parameters) {code block}
Describe the parts of a function call.
function name with ( )
When comparing them side-by-side, what are the differences between a function call and a function definition?
function definition defines the function, while calling the function actually execute the defined function.
What is the difference between a parameter and an argument?
parameter is the placeholder for the argument
Why are function parameters useful?
it could be modified
Why are function parameters useful?
it allows function to pass on
Why do we log things to the console?
to check the result
What is a method?
function which is a property of an object.
How is a method different from any other function?
built into the object
How do you remove the last element from an array?
pop()
How do you round a number down to the nearest integer?
math.round
How do you generate a random number?
math.random
How do you delete an element from an array?
splice
How do you append an element to an array?
push
How do you break a string up into an array?
split
Do string methods change the original string? How would you check if you weren’t sure?
no. and use console.log
Roughly how many string methods are there according to the MDN Web docs?
~40
Is the return value of a function or method useful in every situation?
no
Roughly how many array methods are there according to the MDN Web docs?
~30
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
Give 6 examples of comparison operators.
== , != , === , !==, >,
What data type do comparison expressions evaluate to?
boolean
What is the purpose of an if statement?
to see whether the condition is met
Is else required in order to use an if statement?
no
Describe the syntax (structure) of an if statement.
if (condition) {“code block”}
What are the three logical operators?
&& (both needs to be true)
|| (either one)
! (inverts the boolean value)
How do you compare two different expressions in the same condition?
logical operator
What is the purpose of a loop?
to check the condition and run til it meets the condition.
What is the purpose of a condition expression in a loop?
serves as a counter (how many time it will run)
What does “iteration” mean in the context of loops?
each execution
When does the condition expression of a while loop get evaluated?
before the condition expression
When does the initialization expression of a for loop get evaluated?
evaluated once before the iteration
When does the condition expression of a for loop get evaluated?
after the final expression.
When does the final expression of a for loop get evaluated?
after the iteration
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
break
What does the ++ increment operator do?
increment
How do you iterate through the keys of an object?
for .. in loop
What are the four components of “the Cascade”.
inheritance
source order
specificity
position
What does the term “source order” mean with respect to CSS?
priority on which style gets applied
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance
List the three selector types in order of increasing specificity.
type
Why is using !important considered bad practice?
it can override the specificity
Why do we log things to the console?
to see the result. checkpoint
What is a “model”?
recreation of something.DOM tree, it is stored in the browsers’ memory.
consists of 4 main types of nodes.
Which “document” is being referred to in the phrase Document Object Model?
HTML doc. entire page/ object
What is the word “object” referring to in the phrase Document Object Model?
element
What is a DOM Tree?
the model made of objects
Give two examples of document methods that retrieve a single element from the DOM.
getElementByID()
querySelector()
Give one example of a document method that retrieves multiple elements from the DOM at once.
getElementsByClassName()
getElementsByTagName()
querySelectorAll()
Why might you want to assign the return value of a DOM query to a variable?
to save the browser looking through the DOM tree to find the same element again.
What console method allows you to inspect the properties of a DOM element object?
console.dir()
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
so that javascript loads after the HTML
What does document.querySelector() take as its argument and what does it return?
class,id, element, css selector
gives the location of the node
What does document.querySelectorAll() take as its argument and what does it return?
class,id,element,css selector
return in Node list (array like object)
gives out the whole elements within the DOM
Why do we log things to the console?
to see the result
What is the purpose of events and event handling?
for the user interaction with the page.
What do [] square brackets mean in function and method syntax documentation?
optional
What method of element objects lets you set up a function to be called when a specific type of event occurs?
addEventListener()
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
What object is passed into an event listener callback when the event fires?
event object
What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?
where the interaction occurred. debugger.
What is the difference between these two snippets of code?
2nd one will load right up. (one with the ()) so don’t put ().
What is the className property of element objects?
string with the associated element
How do you update the CSS class attribute of an element using JavaScript?
using className method
What is the textContent property of element objects?
represents the text content of the element property and its descendants.
How do you update the text within an element using JavaScript?
element.textContent =’ ‘
Is the event parameter of an event listener callback always useful?
no
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
Why is storing information about a program in variables better than only storing it in the DOM?
quicker access / securiity