WDI Fundamentals

WDI Fundamentals Unit 10

Your Turn Your Turn

Methods Exercise


  1. Write the code to perform the actions listed below in the "JavaScript" panel in the JS Bin editor.
  2. If you don't see the JS Bin below, please refresh the page.
  3. Click "Run" to run the code in the "Console" panel.
  4. After clicking "Run", to check variable values, type the variable name in the "Console" panel on the right and hit enter/return.

JS Bin on jsbin.com

Let's get started!

  1. In the "JavaScript" panel in JS Bin, create an object poem with the following properties:
author "Robert Frost"
datePublished 1916
name "The Road Not Taken"
famousLine "Two roads diverged in a yellow wood"

2. Now add a method quotePoem to the poem object.

3. Inside the method, add a console.log() statement, logging the famousLine property.

Hint: You'll want to use the this keyword to log out the famousLine property for the poem object.

4. Now call the quotePoem method.

Hint: The syntax for calling a method looks like this:


5. Hit the "Run" button in the "Console" button to test things out!

Stuck? Check out the solutions for assistance.

Ready to move on? Here's the next lesson.