Rebecca's Dev Blog

Javascript, HTML and CSS

HTML and CSS are like the building blocks and appearance of a house. Using HTML you layout the building materials of a house, and with CSS, you decide where and how to put everything together.

Control flow is how a program will execute and run from one function to the next.
Loops are a type of function that repeats until a certain condition is met.

This process is similar to how you would eat dinner. The program could be called eatingDinner for example. There is a step by step process (like the control flow) that you would follow in order to run the full program. Looping would be the function of taking a bite, chewing and swallowing, then repeating that process until the burger is finished. Once the burger is finished then you can move on to eating the fries, and looping the eating process again until either the fries are finished, or you are full. Control flow makes sure that you don't wash your plate until the food is finished or you are full and have kept the leftovers in the fridge. (I am a bit hungry now)

The DOM is short for the Document Object Model, this is basically the structure of the elements within the HTML document. You can use Javascript to access these elements (or nodes) in order to manipulate them, these elements are objects and they have their own properties. For example if you had a todo list on your browser, the actual HTML file might only have one li (list) item inside the ul (unordered list). Using Javascript, you can target that ul element in the HTML file and tell it to add another li (list) element with Bread, then another one with Milk - when the user types it in and clicks add.

When accessing data from an Object, you can target a specific element by using it's name (which is a value) and it will give you it's properties. Example - if you had a backpack (as an object) you can target your lunch (which is leftovers) in the backpack by saying - backpack[lunch] and that should give you leftovers.

However an Array, is like having recipe book full of recipies, with an index number that lists where each recipe is. Example recipe[0] will bring up the first recipe in your book. Or you could loop through the recipe book until you found the index value with the property - cake. You can have arrays in arrays - like having a bookshelf with many books and in each book are many items.

Functions are the method in how you would complete a task. You can target a specific element or group of elements and give instructions to do almost anything. Adding, deleting, moving, searching for information, etc. Functions and be long and complex or simple and just do one thing. By giving the function a name, you can call that function any time you need it.