Skip to content

codesquadkiki/Object-Method-Challenge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Object Method Challenge

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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!

Submission

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.

About

Unit 4.6 - Objects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published