hasOne
Checks if an array has only one value matching the given function.
- Use
Array.prototype.filter()in combination withfnto find all matching array elements. - Use
Array.prototype.lengthto check if only one element matchesfn.
Checks if an array has only one value matching the given function.
Array.prototype.filter() in combination with fn to find all matching array elements.Array.prototype.length to check if only one element matches fn.