LeetCode #202 - Happy Number (JavaScript)

The definition of happy number is from mathematics (see WikiPedia). Basically what is needed to know is that numbers 2-6 are unhappy, while 1 and 7 are.

const isHappy = n => {
    let number = n;
    let digit = 0;

    while (number > 6) {
        let sum = 0;
        
        while(number > 0) {
            digit = number % 10;
            sum += Math.pow(digit, 2);
            number = Math.floor(number / 10);
        }
        
        number = sum;
    }
    
    return number === 1;
}