Does my number look big in this?

JavaScript

function narcissistic(value) {
  let digits = value.toString().split('').map(x => parseInt(x));
  let len = digits.length, sum = 0;
  digits.forEach((num) => sum += Math.pow(num, len));

  return sum == value;
}

CoffeeScript

narcissistic = (value) ->
  digits = value.toString().split('').map (x) -> parseInt(x)
  len = digits.length; sum = 0;
  digits.forEach((num) => sum += Math.pow(num, len));

  return sum == value;

Tags

  1. javascript (Private)
  2. coffeescript (Private)
  3. 6-kyu (Private)
  4. codewars (Private)
  5. answer (Private)