Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Project JavaScript I1 Classes

Topics: Constructor Instance, Methods, Method Calls, Inheritance, Static Methods

Project Title: Traffic Light

  1. Create a html file with your name like john.html
  2. Add current code to that file:
<!DOCTYPE html>
      // your code here
  1. Create class named TrafficLight.

  2. Add color and address to it.

  3. Create an instance myTL and setcolor to red and address to Avenue 1

  4. Add a method named getColor to get color and call with console.log to show into console.

  5. Add a method name canGo that checks color and if it is green returns true, else false.

  6. Create class named VIPTrafficLight inherits from TrafficLight

  7. Add field SpecialEffects to this class.

  8. Create an instance named myVIP and set SpecialEffects to dotted.

  9. Add method getSpecialEffects() to return the effect.

  10. Add method setSpecialEffects() to set the effect. If it not dotted, solid or dashed do not set and log No valid Effect.

Want to get reviewed?

Send Pull Request. Check how to deliver your code:

Need help?

Download Learn JavaScript eBook from

You can’t perform that action at this time.