Frequency Pulse

MediumAcc. 88.4%
+30 XP 12

Precise Occurrence

Counting frequencies is a key part of data analysis. Whether it is scores in a game or items in an inventory, the logic is the same.

The Assignment

Your function receives an array data and a target value.

  1. Use a loop to scan the entire array.
  2. Every time the current element matches the target exactly, increment a count variable.
  3. Print the final count.

01EXAMPLE 1

Inputdata=["apple", "banana", "apple"], target="apple"
Output2

Explanation: "apple" appears twice.

Constraints

  • Iterate through every element.
ArraysLoopsCounting
JavaScript
Loading...
3 Hidden

Input Arguments

data["apple","banana","apple","orange","banana","apple"]
target"apple"

Expected Output

3

Click RUN to test your solution