```
/**
* @param {number} n
* @return {boolean}
*/
function isHappy(n) {
while (n > 6) {
let next = 0;
while (n) {
next += (n % 10) * (n % 10);
n = Math.trunc(n / 10);
}
n = next;
}
return n === 1;
}
```