Topics: Constructor Instance, Methods, Method Calls, Inheritance, Static Methods
- Create a html file with your name like john.html
- Add current code to that file:
<!DOCTYPE html>
<html>
<body>
<script>
// your code here
</script>
</body>
</html>-
Create class named
TrafficLight. -
Add
colorandaddressto it. -
Create an instance
myTLand setcolortoredandaddresstoAvenue 1 -
Add a method named
getColorto getcolorand call with console.log to show into console. -
Add a method name
canGothat checks color and if it isgreenreturns true, else false. -
Create class named
VIPTrafficLightinherits fromTrafficLight -
Add field
SpecialEffectsto this class. -
Create an instance named
myVIPand set SpecialEffects todotted. -
Add method getSpecialEffects() to return the effect.
-
Add method setSpecialEffects() to set the effect. If it not
dotted,solidordasheddo not set and logNo valid Effect.
Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/
Download Learn JavaScript eBook from https://codingwithbasir.com/learn-javascript
