Solving LeetCode 231 in JavaScript (Power of Two)