L
L
Lexikono2020-11-15 00:00:33
JavaScript
Lexikono, 2020-11-15 00:00:33

How to count the number of identical numbers in an array with a function?

It is necessary to calculate using a function that receives an array and a specific number, the amount of this specific number in an array of numbers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WbICHA, 2020-11-15
@Lexikono

nums.reduce((acc, n) => n === numToFind ? acc + 1 : acc, 0);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question