Below are 4 descriptions that will need to turn into an object. Each object has at least one property and a method. For the 5th description, you are asked to create your own object that contains a property and a method.
-
A hotel with two properties called totalRooms and bookedRooms. The values for both properties can be any number. A remainingRooms() method (VERSION 2 - ES6) should return the remaining number of rooms that a hotel has. Console.log a message that says, "There are
##
of rooms available for booking." The ## in this message should be referenced dynamically from the remainingRooms()method. -
A Forest Gump with the property called "thing". The value should be set of chocolates. A sayQuote() method (VERSION 2 - Key/Value Pair) will result in a console.log that says "My momma always said, 'Life was like a box of
chocolates
. You never know what you're gonna get.'" The thing "chocolate" in this message should be referenced dynamically from the property. -
A Instacart with a property "items" initialized to an empty array. A method addItem() (VERSION 2 - ES6) with one parameter, that will eventually add one item to the items array. Console.log the items property to display the items that are currently in the shopping cart.
-
A rocket with the property called "name". The name of the rocket is called "Apollo 11". A startLaunch() method (VERSION 1) will result in a JavaScript alert that says, "ignition sequence start for the
Apollo 11
... 6, 5, 4, 3, 2, 1, 0 ..." This method will also console.log a message that says "launched". The name "Apollo 11" in this message should be referenced dynamically from the property. Remember to call the method. -
Create your own object and give it at least one property and at least one method. You can use any version to create the methods, Then call one of the methods you created. Use your imagination!
Push your code to your Github account and then paste the link to the repo when submitting. If you do not finish in class, submit what you were able to get done.