Aside from arrow functions, 2022.2 also supports for…of loops, which would improve readability.
None of that works in the current version of Connect though.
Your code looks okay to me. Maybe you could refactor it a bit to break out of those loops as soon as you encounter a “Y” since there is no point in continuing after that.
Not sure about performance. I was trying to get it done with the least amount of code possible, but I think readability is more important. Just go with whatever makes the most sense to you.
It’s a good question, it’s just a habit. As a rule I use let instead of var, and const instead of let (where possible). It’s a stylistic choice, just like you can either add a semicolon at the end of each line or choose to always omit semicolons.
Let is block-scoped, which makes more sense to me than function-scoped (especially in for loops). Const is a signal that the variable is never reassigned, which can make the code a little bit easier to read and maintain. But in the end it really doesn’t matter much.