Skip to content

Instantly share code, notes, and snippets.

@code-for-coffee
Created September 26, 2016 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-for-coffee/073a36f91749f220ae220ba188b73ccb to your computer and use it in GitHub Desktop.
Save code-for-coffee/073a36f91749f220ae220ba188b73ccb to your computer and use it in GitHub Desktop.
Object Reps

Object Reps

You will create three Objects.

Pet

  • Create an {} called pet. Assign it 4 attributes.
  • Using dot notation and obj['key'] syntax, console.log() each attribute.

Bike

  • Create an {} called bike. Assign it 3 attributes & 2 methods.
  • Using dot notation only, console.log() each attribute.
  • Two methods should be:
    • pedal: console.log('Going faster!');
    • brake: console.log('Slowing down!');

Car

  • Create an {} called car. Assign it 4 attributes and three methods.
  • Four attributes shoudl be:
    • speed (set to 0)
    • color
    • brand
    • model
  • Using dot notation only, console.log() each attribute.
  • Three methods should be:
    • accelerate: increase speed +1 and console.log this.speed
    • brake: decrease the speed +1 and console.log this.speed
    • toString: console log all of the current properties to tell the world about this car
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment