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 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!
Get Organised!
If you are using Google Chrome on a MAC, remember to use CMD SHIFT C to open the console.
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.
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!
Submit your project folder as instructed by your tutor.
browser file tags body save p html h4 structure refresh organised CTRL SHIFT Jscript console.log