September 28th, 2024
What's missing in this code?
func(['a', 'b', 'C'], 'c'); // 2
func(['A', 'B', 'C'], 'B'); // 2
func(['A', 'B', 'C'], 'b'); // 0
func(['B', 'A', 'C'], 'a'); // 0
func(['a', 'B', 'c'], 'B'); // 2
func(['a', 'c', 'B'], 'A'); // 1
func(['A', 'b', 'A'], 'b'); // 2
function func(arr, theStr) {
const isUpperCase = theStr === theStr.
();
const matches = (str) =>
str ===
(isUpperCase ? str.toUpperCase() : str.toLowerCase());
let count = 0;
for (let i = 0; i <
; i++) {
if (matches(arr[i]) || matches(
)) {
count++;
}
}
return count;
}
Type or select from these options