Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 540 Bytes

arrayCount.md

File metadata and controls

27 lines (17 loc) · 540 Bytes

Back to reference

arrayCount(arr, val)

Counts how often val is contained in arr.

Example 1:

This counts all 3s in randomNumbers:

let randomNumbers = [1, 3, 3, 7];
let count = gmynd.arrayCount(randomNumbers, 3);

// count: 2

Example 2:

This works with any type of data – this counts all "Math"s in timeTable:

let timeTable = ["Philosophy", "Math", "Math", "English", "History", "Physics"];
let count = gmynd.arrayCount(timeTable, "Math");

// count: 2