boat

Javascript

interactive web design

 

The Human Brain

The human brain is amazing.

It is able to store information in brain cells and process that information.

Information is stored in memory and retreived when needed.

A computer program

A computer program is quite similar.

It stores information in memory and retreives that information when necessary and processes it.

Computer programs do not use brain cells to store information, though!

They use variables.

Let's get started with Javascript!

   Starting with Javascript

TASK 1

Get Organised!

 
Create a folder called Javascript.
 
Create a project folder called JFocus1 inside the Javascript folder.
 
Download html document and save it in your JFocus1 project folder.
 
open jFocus1.html in a Web Browser AND a Text Editor, eg Sublime Text.

Task 2

Watch the starter video and follow what happens using your text editor and web browser.

TASK 3

If you are using Google Chrome on a MAC, remember to use CMD SHIFT C to open the console.

 
In the script section, create three more variables and assign your own personal data to them.
  • myHometown
  • myEmail
  • myVeryVeryFavouriteFlavourOfPizza
 
Use Javascript to write sentences using console.log eg My favourite pizza is RedHotSpicyBeans. I am from Osaka.

TASK 4

Under your current javascript, write the following and test it:

console.log("It is my birthday!");

myAge = myAge + 1

console.log("So, now I am ",myAge," years old!");

Notice that we updated the data stored in the variable myAge. Because we already told Javascript that this is a variable, we don't need to use the var keyword again.

TASK 5

To calculate your age in days, we will simply multiply myAge by 365.

Create a new variable called myAgeInDays.

Can you figure out how to assign the correct data to this new variable and how to create a sentence in the console log?

Hint: talk to your classmates and share your ideas!

SUBMISSION

Submit your project folder as instructed by your tutor.


Tags

browser file tags body save p html h4 structure refresh organised CTRL SHIFT Jscript console.log