Need some help with a javascript problem

User Generated

fnzennw

Computer Science

Description

Not sure how asynchronous callbacks work. I have code like this:

  1. var count = 0;
  2. $('.count').each(function() {
  3. count++;
  4. }
  5. console.log(count);

So would i have to go through each of the elements independently with a traditional for loop in order to get a count to appear correctly? Or would this get the count?

Thanks Love_Struck

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer


Anonymous
Just what I needed…Fantastic!

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags