Week 4-JS Conditional Exercise – Milly Cai

Here is the link to the page:

http://imanas.shanghai.nyu.edu/~yc2966/week04/index.html

The final view

  

Code

Problem & what learned:

As the exercise requires us to loop the actions. Thus, I created an if-conditional loop, which checks the time you click the button by calculating the remainder of the clicking times dividing by 3. It works well.

The biggest problem I’ve met in this exercise is that I used the getElementsByClassName to assign the value to the variable I created in the javascript file. As a result, it always turned out to be an error in the code getting the element. After asking Cindy about this problem, I learned that get a class name will offer me an array, which I need to call the index of the element to get what I want exactly; while getting element by the id will directly lead to the exact value. This is a useful lesson for me.

Leave a Reply