Paige Moore
Dev Blog

fancy letter P

Javascript DOM

An analogy to describe the differences between HTML and CSS

I think i would like to use the body as my analogy. the HTML is the bones of the body, the structure. The CSS is the skin, the hair, the appearance of the body. Without HTML, CSS doesn't have anything to cover and style. Without CSS, HTML is just a bunch of bones.

Explain control flow and loops using an example process from everyday life

for loop - The main reason for choosing loops is to go through the process until we get something that meets the conditions. For example - Dev Academy, we are given subject to read, we will keep reading the subject material over and over until we can pass the subject. If we were to have the facilitator marking out work as we go. We start at 0 and then work our way up, after 50 for each correct answer you feel more relieved. while loop - you only have one condition - whether you pass or not.

Describe what the DOM is and an example of how you might interact with it.

The Document Object Model (DOM) is a programming interface for web documents, that defines the logical structure if the documents and the way the document is accessed and manipulated either through browser or HTML. You interact with the DOM through methods, for example, getElemenById(). this method returns the element that contains the same ID passed. ID's should be unique so its an easy way to get the element you want. (var element = document.getElemenById(id);)

Explain the difference between accessing data from arrays and objects.

Objects - are used to represent a thing in code, anything that can be defined by a set of characteristics. In objects, these characteristics are called 'properties' that are made up of key and value. properties in objects can be accessed, added, changes or removed by dot or bracket notations. Arrays are basically a list of multiple items in a single variable. Items in an array can be in ordered collections, where the items can be accessed by their numerical position in the list.

Explain what functions are and why they are useful.

A function is a block of code made to perform a specific task, much like a procure. A function is executed when something calls it. Within the function it needs to have a set of statements that perform a task and a return statement to make it stop executing. Functions are handy because they can be used many times with different arguments to produce different results.