Skip to content

Instantly share code, notes, and snippets.

@ATMartin
Last active December 4, 2015 14:50
Show Gist options
  • Save ATMartin/0a07e013a423c10cdde2 to your computer and use it in GitHub Desktop.
Save ATMartin/0a07e013a423c10cdde2 to your computer and use it in GitHub Desktop.

Constructors

We'll practice using constructors and assigning to object prototypes in Javascript.

You Should Know

  • Javascript constructors
  • Javascript prototypes
  • Browser tools

Your Mission

We've assembled some challenges covering Javascript constructors and prototypes. We'll complete these challenges in such a way that we can test the solutions using our browser's Javascript console.

Explore Mode

Challenge 1.1: Download constructors.js and include it in a simple webpage called index.html. Complete challenge #1 through #5 inside constructors.js. Open your webpage locally and use your browser's console - if you see "Assertion failed", you need to recheck your work.
Goal 1.1: Upload both files to Github pages and submit your page's URL below.

Adventure Mode

Challenge 2.1: In addition to Explore's objectives, complete the "Bonus" challenge in constructors.js.
Goal 2.1: Submit your Github page URL below.

Epic Mode

Challenge 3.1: In addition to Adventure's objectives, create a new file called animal.js. Include it in your index.html and, without changing your solutions to constructors.js, add a method called walk() to both Cat & Dog's prototypes. Cat.walk() should return the string "Nope", and Dog.walk() should return "Hooray!". Make sure you add animal.js to your page and update your Github page.
Goal 3.1: Submit your URL below.

Requirements for Completion

  • Github Pages URL

You May Need

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment