Giter VIP home page Giter VIP logo

javascript-assignment-2's Introduction

Javascript Assignment #2

Understanding Javascript conditions and loops

Assignment

  1. Fork this repo.

  2. Only code inside the file named script.js. No editing any other files.

  3. Write a for loop to add a click event listener on all divs with class box.

  4. When the user clicks any box, change that box's background color to one of the following colors.

    • If number of boxes on the page is between 201 and 300, inclusive, change the background color of the box to 'yellow'.

    • If number of boxes on the page is between 301 and 400, inclusive, change the background color of the box to 'green'.

    • If number of boxes on the page is between 401 and 500, inclusive, change the background color of the box to 'purple'.

    • If number of boxes on the page is between 501 and 600, inclusive, change the background color of the box to 'orange'.

    • If number of boxes on the page is between 601 and 700, inclusive, change the background color of the box to 'pink'.

    • If number of boxes on the page is between 701 and 800, inclusive, change the background color of the box to 'black'.

    • If number of boxes on the page is between 801 and 900, inclusive, change the background color of the box to 'brown'.

    • Otherwise, change the background color of the box to 'blue'.

For extra credit

  1. In the click event function, change that box's class to clicked. If it's already the class of clicked, change it back to box. Basically, if a box is clicked, it should toggle between the css class of box and clicked.

javascript-assignment-2's People

Contributors

esosa0 avatar

Watchers

James Cloos avatar  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.