- Open the project in Visual Studio Code
- Start the Live Server
- Open the Console tab on Chrome's DevTools
-
Define a new object called
dog:- Give it a property
name, set it to any value - Give it a method
bark, which will log"woof!"to the console when invoked - Log
dog.nameto the console - Invoke
dog.bark() - Log
dogto the console
- Give it a property
-
Update the method
barkabove to say"woof, I'm <name>!"- e.g. if
dog.nameis"Timmy",dog.bark()should print"woof, I'm Timmy!"on the console
- e.g. if
-
Define a new object called
person- Give it a
firstNameproperty - Give it a
lastNameproperty - Give it a
namemethod that returns the full name of the person - Give it a
birthYearproperty - Give it an
ageThisYearmethod that returns the age of the person- e.g. if
person.birthYearis2000thenperson.ageThisYear()should return18
- e.g. if
- Give it a
-
Define a variable called
someStringwith any string as its value -
Log the above string's
lengthproperty to the console -
Set the
lengthofsomeStringto another number e.g.200 -
Log the
lengthproperty ofsomeStringto the console again. Did it change? Why or why not? -
Explore some more string methods e.g.
toLowerCase(),replace()etc. ([refer to MDN][mdn-string]) -
Create a variable called
decimalNumber, giving it some numeric value -
Use the
toFixed()method to convert the number to a formatted string with 3 decimal places, and log it to the console -
Declare a function
sumthat takes in two arguments and returns the sum of the two arguments -
Log the value of the
sumfunction'snameproperty to the console -
Log the return value of the
sumfunction'stoString()method to the console