Counts how often val
is contained in arr
.
This counts all 3
s in randomNumbers
:
let randomNumbers = [1, 3, 3, 7];
let count = gmynd.arrayCount(randomNumbers, 3);
// count: 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