0

So on my website i have a counter that increases every time a form is submitted. When the amount of entries to that form hits 40 or every 40 after that i want to do something. So if i have 79 entries i do nothing. But once someone submits the 80th entry i show them something special with javascript.

  • 2
    See the remainder operator (`%`), sometimes (somewhat incorrectly) called the modulus operator, referenced by the [linked question's answers](https://stackoverflow.com/questions/2821006/find-if-variable-is-divisible-by-2), it works for 40 just as well as for 2. E.g., `if (counter % 40 === 0)`. – T.J. Crowder Dec 22 '21 at 11:10
  • But say the counter is at the 120th entry then the above output would be 3 not 0. – Joris Menke Dec 22 '21 at 11:18
  • No, `120 % 40` is `0`. (I suggest checking things like that before writing them.) It's a **remainder** operation, not division. Please read the linked answers. – T.J. Crowder Dec 22 '21 at 11:23

0 Answers0