Code Monkey home page Code Monkey logo

traffic-light's Introduction

Traffic light

Open the index.html in a web browser to see the traffic light. You can look at it online as well.

You need to make the traffic light toggle between green, red and orange based on the values entered into the textbox on the left hand side of the screen.

If the value in the textbox is more than 40 switch on the green light, if between 40 and 30 switch on the orange light otherwise the light should be green.

Functions provided

Write your code in the conditional-logic.js file. Functions are provided to you to control the traffic light.

Use:

  • go - to switch on the green light.
  • stop - to switch on the red light.
  • caution - to switch on the green light.

The value entered in the textbox is available in the captureTrafficLightChange function. Write your code in there.

Challenge

Can you make the light change automatically? You can use the setInterval function. Open set-interval.html in a browser, you should see a number incrementing. Add logic in the interval function to make the counter reset to 0 once it reach 60. How do you integrate this into your traffic light to make it change color automatically.

traffic-light's People

Contributors

codex-avee avatar

Watchers

Angelo Pearce avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.