There's a few general code hygiene things that I'll look at first, and then I'll comment on the algorithm design.
const array but it's still confusing to use it with a variable whose job is to change.
const arr I like but
const resultArray I don't.
Second, although I appreciate that these practice challenges don't always give a huge amount of context to inform your purpose, it's important to think about variable names. In particular,
arr is a very vague name at the best of times, and a moderately misinforming one in this context. I'd go for something like "instruction".
Third, three if statements checking the same expression for fixed values just screams "use a switch statement". Efficiency questions notwithstanding,
switch will immediately clue anyone reading the code into there being one value to check against several options. (Whereas with long
else if chains we have to focus on each condition because they could be different)
Fourth, avoid this little trick:
frequencyArray[arr] without having to worry about whether
arr being enormous. With that direct value lookup, your cases for
2 both consist of very quick operations. Case
3 is the one that will take time, even though it looks just as simple as the others. It's the
includes function that's killing you. While the other cases just check one value in the array,
includes has to check every single value. What you'll want to do is remember your frequency count as you go, taking a bit of extra time in your
2 cases to update an additional array/dictionary, so that in your
3 case you can just look up that already calculated value and output it.