How to solve the Leetcode 1657. Determine if Two Strings Are Close problem in JavaScript