Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
How to make a simple counter function in JavaScript that increments on a condition

I am currently working on a simple javascript counter that should have a variable named "seq" set to 0 on page load, and increments every time a button is clicked. I've created a function of what I think it should look like, but am not sure if it is the right approach. Any suggestions? Thanks.

var seqcounter = function () {
  seq = 0;
  document.getElementById("myBtn").addEventListener("click", function () {
    seq++;
  });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Mybe better to write this way :

var seq = 0;
var increaseSeq = function (){
seq++;
}

document.getElementById("myBtn").addEventListener("click",
increaseSeq
//change with help of @peter seliger
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!