JavaScript Fundamentals

HTML

What is the difference between HTML and CSS?

A HTML file contains the structure of the page itself. It is kind of like the structure of the building.

A CSS file contains the styling of the page. It allows you to change styles such as colors, positioning etc... It is kind of like the design of the building itself.

JavaScript: Control flow and Loop

Control flow in JavaScript is how your computer runs code from top to bottom. It is similar to the step of buying tickets by using ticketing machines.
For instance, when you buy tickets by using the machine, you pick the ticket which you would like to buy and then you insert money.
If you put money more than ticketing cost, you will receive the changes and ticked otherwise you will get the ticket.

Loop is used in JavaScript to perform repeated tasks based on a condition.
For instance, everyday you cook or buy food for your meals. It could be called "loop" in programming. Firstly, when you feel hungry, you would thik if you have enough food at home or you have to buy food at supermarket or take away shop. After having meal, you would not feel hungry anymore. (that's the ending the food loop!)

JavaScript: What is the DOM?

The DOM means the Document Object Model and is the data representation of the objects that comprise the structure and content of a document on the web.

Sample

If you click the below button, the text color will be changed. This is one of the DOM interaction.

Hello

What is the difference between accessing data from arrays and objects?

Objects

Objects is everywhere in JavaScript.Objects are mutable data structure in javascript which is used to represent a ‘Thing’. This could be anything like cars, plants, person, community etc. It stores 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.

Array

Array can store a list of items or objects in a single variable.The data can be modified at any index.

JavaScript: What is function? Why they are useful?

In JavaScript, a function allows you to define a block of code, give it a name and then execute it as many times as you want.
It is useful because you do not need to type out the same code multiple times. It is like you have your own shortcut system.