Home Tech Blog Human Skills

Javascript Dom.

Describe JavaScript and its relationship to HTML and CSS.

HTML, CSS and JavaScript are all things used for a website and have different purposes. HTML holds the content for the page, CSS stylizes the layout/design but what does JavaScript do? JavaScript uses logic to allow us to interact with and manipulate both HTML and CSS which allows us to do funky this like below.

An example of JavaScript!


Example Of The JS Above

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

Control Flow is the order in which JavaScript code is executed and allows us to control the direction of program. Loops is also a type of control flow and allow us to repeat something a set amount of times until it completes the specified amount. My everyday example of this would be this: Whenever I'm playing a game and face a difficult boss I will always fight it till its defeated, but sometimes its a lot harder than normal so it slowly chips away at my sanity and when that happens it looks a little like this:

loop example

Basically my sanity starts out at 100, then while my sanity is greater than 0 I will continueously loose sanity with my sanity--. If my sanity is above 50 or equal to I'm still confident otherwise if its less than 50 I struggle badly.

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

DOM stands for Document Object Model and its the structure of a website that allows us to interact/modify with websites using JavaScript. An example of this would be a person; The skeleton is HTML, Muscles/Organs are Javascript, CSS is the clothes and your brain is DOM.

Explain the difference between accessing data from arrays and objects.

Arrays store data in consecutive locations and always starts at 0 like: array = [0, 1, 2, 3]
Where as objects are stored in named key values like: person = {name: 'Sasha', age: '20', something else: true}.

Arrays are better for lists and objects are better for detailed labeled information.

Explain what functions are and why they are helpful.

Functions is a block of code containing a set of statements and loops to preform tasks. They are helpful as they allow us call them and reuse them without the need to repeat everything inside of them.

The End.