๐ Remember to test each of your answers!
- Make an object called
clicker
, which has aclickCount
property, and aclick
method. - Have the
click
method increment theclickCount
by 1 each time it is called.
๐ด The commit message should read:
"Commit 1 - Clicker done"
- Create an object called
myInformation
. - Assign to it your name, your current age, and a fact about you.
- Inside
myInformation
, create a method calledstatement
that returns a statement about you including your name, this fact, and how old you will be in 10 years. - Inside
myInformation
, create another function that can be used to increment the value of your age by 1 each time that you call it. - It's your birthday! Call this new method that you made that will increase your age.
- Create another function that can be used to change the value of your
name
. - You're feeling funky and decide that your new name is
Rumpelstiltskin
. Call the method that will update your name and assign this new name. Log your object to confirm the changes.
๐ด The commit message should read:
"Commit 2 - It's all about Me done"
- Create an object called
greeter
. - Inside the
greeter
object, create a method calledhello
that takes a name as a parameter and returns a greeting message followed by thename
parameter.
Example:
Oh hello there, Matthew
- Create another method inside
greeter
calledgoodbye
that takes a name as a parameter and returns a farewell greeting followed by thename
parameter.
Example:
Arrivederci, Matthew!
- Create a final method inside
greeter
calledwhoAreYou
that takes a name as a parameter and returns "Oh right! ", followed by thename
parameter, followed by " how could I forget...!"
Example:
Oh right! Matthew how could i forget...!
- Play around executing your functions by accessing them through the object.
๐ด The commit message should read:
"Commit 3 - Greeter done"
Make an object called stringCollector
, which has:
- a
collection
property - an array to hold strings - a
collect
method which takes a string as a parameter - the string collector prefers the strings to be totally reversed in their collection, however, so make sure to reverse it before adding it to the collection
- add an
admireCollection
method which prints out each string in the collection to the console, one line at a time
๐ด The commit message should read:
"Commit 4 - Collecting Strings done"
Make an object called atm
which has two properties:
totalCash
, the total amount of cash in theatm
dispenseTwenties
, a method with takes a number of twenties and, if there is enough cash, returns the total number of cash it is giving out.- If there is not enough cash, return
null
instead.
For example, if the
atm
has200
dollars left, the call todispenseTwenties(6)
should return120
, and update thetotalCash
to80
. However a call todispenseTwenties(11)
should returnnull
.
๐ด The commit message should read:
"Commit 5 - ATM done"
- Create an object called
Leonardo
. - Leonardo should have a name attribute of "Leonardo", a color attribute of "Blue", and a weapon attribute of "Katana".
- Leonardo should also have a boolean property called pizzaEaten that is initially set to false.
- Add a method to Leonardo called eatPizza() which does the following:
- If pizzaEaten is true, print out "Leonardo has already eaten pizza" and set pizzaEaten to false.
- If pizzaEaten is false, print out "Leonardo is eating pizza" and set pizzaEaten to true.
๐ด The commit message should read:
"Commit 6 - Hungry Turtles done"
- Create an object called
calculator
- Create a property called
output
- Create a method inside your object that will multiply two numbers and change the
output
value to this current value. This method should also log the value ofoutput
. - Create a function that will divide two numbers. It should also change the
output
value to this current value. This method should also log the value ofoutput
. - Practice using your calculator with some pairs (10, 2), (-2, 8), (2, 2).
- If there's additional time, add methods for
addition
andsubtraction
๐ด The commit message should read:
"Commit 7 - Calculator done"