Why it comes to `SyntaxError: Unexpected token var` in JavaScript?


  • 0
    J
    /**
     * @param {number} num
     * @return {number}
     */
    var findComplement = function(num){
      return (
        Math.pow(2, num.toString(2).length) - 1
      )
      ^ num
    }
    

    But the result is right when I use node@8.5.0 in my PC


Log in to reply
 

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