Lessons 101 to 103 – Complete 2020 Web Development Bootcamp

Lesson 101 – Javascript Alerts – Adding Behaviour to Websites

MDN is a good source of information on Javascript.

This javascript command will cause an alert pop up box to appear on the screen. The pop up box will have the message “Hello World!”.

alert("Hello World!");

The word “alert” is the Javascript function and the message is contained inside the brackets and quotes – in this case – Hello World!. The semicolon brings the function to an end.

In this example, you can use either double quotes around the words “Hello World!” or you can use single quotes – ‘Hello World!’. Javascript will recognize either one. Most programmers use double quotes for a string of text.

This site is a good guideline for the right syntax and structure for Javascript.

Lesson 102 – Data Types

Anything enclosed in quotations is interpreted by Javascript as being a string of text and not a part of the code. A string of text is a data type.

Some other data types are:

  • Numbers;
  • Boolean – this is a data type that describes data as being either true or false.

The function – typeof() – will tell you what the data type is of whatever you put inside the brackets. For example,


will return – “number”. And


will return – “string”. And


will return – “boolean”.

Lesson 103 – Javascript Variables

A prompt is very similar to an alert but a prompt allows a user to input something like a piece of text. This is an example of a prompt:

prompt("What is your name?");

This is an example of a variable –

var myName = "Shane";

The word “var” is a keyword which tells us that we are creating a new variable or data container.

The name of the data container or variable in this case is – myName.

The variable called “myName” is set to be equal to the text string “Shane”.

Once the variable “myName” has been assigned a value of “Shane”, then from that point on Javascript knows that when we refer to “myName” we mean “Shane.

The word “var” is only used when constructing a new data container. Once the container has been constructed you can change what is held within that container by simply referring to the name which you have already assigned to that container.

Using the above example. the variable of “myName” has been created and has been assigned the name “Shane”. If I want to change the meaning of the variable “myName”, I can do so as follows:

myName = "Joe";

I don’t have to use –

var myName = "Joe";