- 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.name
to the console - Invoke
dog.bark()
- Log
dog
to the console
- Give it a property
-
Update the method
bark
above to say"woof, I'm <name>!"
- e.g. if
dog.name
is"Timmy"
,dog.bark()
should print"woof, I'm Timmy!"
on the console
- e.g. if
-
Define a new object called
person
- Give it a
firstName
property - Give it a
lastName
property - Give it a
name
method that returns the full name of the person - Give it a
birthYear
property - Give it an
ageThisYear
method that returns the age of the person- e.g. if
person.birthYear
is2000
thenperson.ageThisYear()
should return18
- e.g. if
- Give it a
-
Define a variable called
someString
with any string as its value -
Log the above string's
length
property to the console -
Set the
length
ofsomeString
to another number e.g.200
-
Log the
length
property ofsomeString
to 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
sum
that takes in two arguments and returns the sum of the two arguments -
Log the value of the
sum
function'sname
property to the console -
Log the return value of the
sum
function'stoString()
method to the console