JavaScript basics

resize browser window to see the page change

How does JavaScript compare to HTML and CSS?

JavaScript is a programming language while HTML, and CSS are not.

HTML and CSS provide static structure that can be manipulated and changed dynamically by JavaScript. It also allows creating web pages that react to what user is doing.

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

Control flow describes a feature of program in specific order. For example, the statements may be processed from top to the bottom in linear order. One can introduce disturbances in the flow of control by using conditional (if, else, and switch) and looping (while, do, and for) statements.
Simple example of control flow is when you turn on the Netflix, then first you check is whether your favourite Doctor Who tv-series still has any unwatched episodes, it this is true then you turn Doctor Who on. However if this is false, and your fav tv-series has already finished, you turn on Daredevil, which is waiting in a line next to watch.

Loops help us to handle repetitive aspects of the program. Imagine that you get into a bus, which starts the loop, you get in and start checking each stop until the one when you want to get off the bus and exit the loop. This process repeats each time you use the bus, no matter on which stop you'd like to exit each time.

Explain the difference between accessing data from arrays and objects.

Data in arrays are accessed via an index while data in objects are accessed via a property name.

Explain what functions are and why they are useful.

Functions are reusable pieces of code. They allow to save time and to manage complexity by enclosing piece of functionality in function body.