Happy Number — JavaScript easy interview problem
A happy number is a number defined by the following process: - Starting with any positive integer, replace the number by the sum of the squares of its digits. - Repeat until the number equals 1 (happy), or it loops endlessly in a cycle (unhappy). Return `true` if `n` is a happy number, else `false`. Example: `isHappy(19)` → `true` because 1²+9²=82 → 68 → 100 → 1.
Tags: set, math
Practice this HashMap & Set problem free in the JS Interview Playground with automated tests and unlockable solutions.