JavaScript Basics

Sprint 4.1

14 September 2018

  1. How does JavaScript compare to HTML and CSS?
  2. JavaScript seems much more involved than just getting the correct structure in order to display content in the right way. JavaScript allows interactivity as the code will produce different results depending on what the user does.

  3. Explain control flow and loops using an example process from everyday life, for example 'waking up' or 'brushing your teeth'.
  4. They are conditional statements which produce a different result depending on what the input is. For example, walking the dog. IF I didn't sleep in, & it's not raining, then I will walk him before work. Otherwise, if I didn't sleep in, and it is raining, and the forecast for the afternoon is fine, then I will walk him after work. If I did sleep in, whether it is raining or not, I will walk him after work. These variables determine the outcome, and include and exclude different factors to reach it.

  5. Explain the difference between accessing data from arrays and objects
  6. Accessing data from an array you can use data[num] (num being the index number of the data you want to receive from the array, starting at 0 for the first piece fo data.) To access data from an object you can use the group name and the property of the data you need using groupName.data or groupName[data].

  7. Explain what functions are and why they are useful.
  8. A function is a piece of code which has a particular purpose or function. Functions are useful because you can refer back to functions many times without having to rewrite it - you just change the variable.