Skip to content

How to use foreach loop in js #22

Answered by Shivam-fibo
siddhartha038 asked this question in Q&A
Discussion options

You must be logged in to vote

There is miner mistake in this code

const arraySparse = [1, 3, /* empty */, 7];
let numCallbackRuns = 0;

arraySparse.forEach((element) => {
  console.log({ element });
  numCallbackRuns++;
});

console.log({ numCallbackRuns });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by siddhartha038
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants