locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
13 lines (12 loc) • 534 B
JavaScript
import { pythonCountOf } from "../_helpers/_operator.js";
export function countOf(a, b) {
// discuss at: https://locutus.io/python/operator/countOf/
// parity verified: Python 3.12
// original by: Kevin van Zonneveld (https://kvz.io)
// note 1: Counts occurrences in strings and arrays like Python's operator.countOf.
// example 1: countOf([1, 2, 1, 1], 1)
// returns 1: 3
// example 2: countOf('banana', 'a')
// returns 2: 3
return pythonCountOf(a, b);
}