1.0.5 • Published 2 years ago

@romulorod/array-count v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

This package is meant to count how many of given elements exists in a given array.

You must import the package and then use it like this:

const arrayCount = require("@romulorod/array-count");

const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const result = arrayCount(array, 5);

console.log(result); // 1

This function can also be used with strings:

const arrayCount = require("@romulorod/array-count");

const array = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"];

const result = arrayCount(array, "a");

console.log(result); // 1

It will also work with nested arrays:

const arrayCount = require("@romulorod/array-count");

const array = [
	[1, 2, 3],
	[4, 5, [2, 2]],
	[7, 8, 9],
	[10, 11, 2],
];

const result = arrayCount(array, 2);

console.log(result); // 4
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago