Skip to content

muhanma/javascript-assignment-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 70.9%
  • HTML 17.8%
  • CSS 11.3%