0

i want to change color of text by clicking button with javascript. I have problem with my code. It's changing color, but counter variable is not resetting to value of zero.

IMAGEstack.imgur.com/sFwbb.png

3
  • 2
    It should be counter = 0 while resetting and NOT counter === 0, counter === 0 is a condition and NOT assignment. Commented Oct 1, 2018 at 18:53
  • Also the the rest of the code should not be wrapped inside else, unless you want to skip that button click that resets counter to 0 Commented Oct 1, 2018 at 19:06
  • Do not use an image to show your code. Place the example code inside the question. Commented Oct 1, 2018 at 19:14

1 Answer 1

1

On line 8 your are doing a comparison check using triple equals "===" instead of an assignment using the "=". In order to set the value of a variable use the assignment operator "=". Your new code will be this on line 8:

counter = 0;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.