JS Fundamentals

An analogy to describe JavaScript and its relationship to HTML and CSS.

The relationship that Javascript has with HTML and CSS is like a bulding bike. ,
For example, HTML is the skeleton of the bike. Then CSS are the different colours applied to the bike to
that made the bike full of live. Finally, CSS is the element that makes the bike stop, change the speed
and brake.

Explain control flow and loops using an example process from everyday life,
for example, 'waking up' or 'brushing your teeth' (but not those).

A control flow is an order in which the instructions of a program are executed. Instructions
execute sequentially. One after another, in order of appearance, from left to right and from
top to bottom. For example, if the condition fulfils, do this; if it is not, do something else.
To have a better understanding, this is an example of everyday life.
Pedrito is a child who wants to make a cake. For Pedrito to make that cake, he must follow
a recipe. The recipe reads from top to bottom. Every time Pedrito adds an ingredient to
the cake, he must see if the recipe says it is fulfilling. If not, the cake will let Pedrito
know that the formula is not fulfilled and that he would love to learn how to

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

DOM is a document object module document that refers to the HTML document. On the other hand, Object refers to each
of the HTML elements as p,h1 and head. For example, when we work with the DOM. An HTML tag, attributes,
comments, texts and line breaks are considered objects, but they are actually called nodes because
the dom sorts HTML elements into nodes, like a tree. Finally, the module refers to the extructure of objects within HTML elements. The job of the DOM is to grab the HTML elements and convert them into objects. These objects are arranged in a tree structure, like the picture below.

Dom
It is organized hierarchically, making it easier for the browser to interpret the code we write.

Explain the difference between accessing data from arrays and objects.

Objects store the data in key value pair and the key can be anything except for undefined. The keys are iterable and can be accessed in any order that can be used to represent a book, a car or a cat. In contrast, arrays are objects only in javascript. The major difference is that they store the data in an ordered collection in which the data can be accessed using a numerical index.
Object
array

what functions are and why they are helpful.

A function is a procedure, a set of statement that perform a task or compute a value. In javascript, functions are objects. Therefore, they can be assigned variables, arrays or other objects. how we have defined our function will define its fehaviour.
Dom