isHappy = (n) => {
    const cycles = [ 4, 16, 37, 58, 89, 145, 42, 20 ];
    const seen = new Set(cycles);/* Time O(1)      | Space O(1) */

    const hasCycle = () => ((n === 1) || (seen.has(n)));
    while (!hasCycle()) {        /* Time O(log(N)) | Space O(1) */
        n = getNext(n);
    }

    return n === 1;
}
Hash Set - seen static
Time O(log(N)) | Space O(1)
https://leetcode.com/problems/happy-number/
@param {number} n
@return {boolean}