This question got closed. Initial close comment:
3 counts on that and 2 for broken code/code not written. In chat it turned out one of them hit the wrong button and the other had a slightly different opinion on what we call 'code not written yet'.
While we all agreed it wasn't a good question but we didn't agree whether it was within scope.
In my opinion, it's asking a very specific question. It wasn't asking for a review, it was asking an alternative for a small piece of the code. When in doubt, I take this table and the on-topic help center as guideline as to what 'type' of questions are on-topic.
Do I want feedback about any or all facets of the code?
OP doesn't. OP wants a specific piece rewritten in a particular way.
I think this comment summed it up:
I think you're looking for a very specific alternative. You can either ask for a full review on the current code, in which case we need context. Or you can go with a specific question to Stack Overflow and use the current code as proof of prior research.
Should we consider such questions on-topic or not?