Exercise

Once again, this exercise will take place in the developer console and will test your knowledge of the above concepts. These concepts form the core of JavaScript and it’s extremely important you have a firm grasp on how they work. If you are unable to complete this exercise with the expected output, please revisit the above content and attempt it again. It’s important that you don’t try to progress further without understanding these basic operators:

  1. Open up the developer console.
  2. Create a variable and assign it a string with the following text ‘my age is’.
  3. Now create a new variable and give it a number corresponding to your age.
  4. Now concatenate the second variable to the first, ensuring legibility. Experiment with adding a colon between the text and the number.
  5. Now output this variable back to the console.
  6. Ensure it renders like so: ‘My age is: 00’ where 00 is your inputted age.

Functions

Functions are the building blocks of a piece of JavaScript code. They are reusable snippets of code that perform an action (or task). Functions are run (executed) when something ‘invokes’ or ‘calls’ it. This might sound complicated, but once you see a few examples it will all become clearer. Let’s kick off with a nice and easy function for us to analyse: