In this unit, we will be introduced to the <script> section of a webpage.
We will see how to create a variable using var.
We will see how to assign data to a variable using =.
We will see how to use your browser's console.
var age = 15;
console.log("Oh, today is your birthday!");
age = 16;
We are telling the browser that age is a variable where we will store some data.
Later we can update the data in the variable age without using the keyword var again. This is because the browser already knows that age is a variable.
It will also introduce variables and how to use your browser's console.
If you are using Google Chrome, remember to use CTRL SHIFT J to open the console.
console.log("It is my birthday!");
myAge = myAge + 1
console.log("So, now I am ",myAge," years old!");
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.