JavaScript with Map and Reduce


  • 0
    Z

    /**

    • @param {number} n
    • @return {boolean}
      /
      var isHappy = function(n) {
      while(n !== 1) {
      if(n === 4) return false;
      n = n.toString().split('').map(a => a
      a).reduce((x, y) => (x + y))
      }
      return true;
      };

  • 0
    A

    should build depend with jdk8+


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.