An analogy to describe the differences between HTML and CSS:
HTML is the content of the page and by itself can be reasonably bland or boring to look at. Which is why we have CSS that comes in adds style and color to our content, positioning it, and controlling what any of the HTML looks likes down to a fine scale.
An analogy for this would be baking for example - you have baked all the core structure for a pretty cool looking dragon cake (your HTML) but without frosting or decorations it's pretty plain and boring. So CSS would come in and the decorations and frosting to make it a lot more awesome to look at.
Flow control in Javascript looks at a function and decides to do one thing(if), instead of another condition(else).
An example would be if you were thinking of going fishing the next day if the weather was fine; else you were going to chill at home and read a book or watch some Netflix.
This would like:
- Wake up, check weather.
- If weather fine = true
- Then go fishing
Else (weather fine = false)
Stay at home and chill
Describe what the DOM is and an example of how you might interact with it:
The Document Object Model or DOM is an interface, and representation of HTML within a document (within a Window).
This is usually displayed family-tree style, starting (keeping it simple for now) the head tag, which is referred to as a node.
The head tag would have a few children made up of title, link, and style.
Then you would have the html node, this would have children which would consist of the content on the page such p, a, img etc.
An example of how you would interact with it is through the DevTools built into Chrome which lets see you view, interact with, and change the DOM. Any changes made are displayed on the page, but only locally - as soon as you refresh the original content will be back
Explain the difference between accessing data from arrays and objects.
Arrays store multiple types of the same information, such as strings “word”, numeric 1, boolean (true/false).
Now these are stored in order from 0 to 9 (or more), for example myArray = “learning”, “to”, “code”.
If wanted to access the string “learning” in myArray it would be 0, so I would query myArray[0] which would give me “learning”
Objects store similar data but are referenced differently to get the data; this is done by using myArray.property.
For example myArray = {
Learning: “Is”,
To: “sort of “,
Code: “hard”,
}
So if I wanted “learning” I would use myArray.Learning, which would return “Is”.
Explain what functions are and why they are useful.
Functions are like the building blocks of Javascript, they are a set of statements that do anything from calculating, or multiplying numbers; to performing a task if a certain requirement is met.
They are useful because they can delete, splice, or create new data depending on what has been in the statement, and can be used to make simple things like todo lists.