--- id: 69cfca90e8a0a6d4d6871c52 title: "Challenge 268: Narcissistic Number" challengeType: 28 dashedName: challenge-268 --- # --description-- Given a positive integer, determine whether it is a narcissistic number. - A number is narcissistic if the sum of each of its digits raised to the power of the total number of digits equals the number itself. For example, 153 has 3 digits, and 13 + 53 + 33 = 153, so it is narcissistic. # --hints-- `isNarcissistic(153)` should return `true`. ```js assert.isTrue(isNarcissistic(153)); ``` `isNarcissistic(154)` should return `false`. ```js assert.isFalse(isNarcissistic(154)); ``` `isNarcissistic(371)` should return `true`. ```js assert.isTrue(isNarcissistic(371)); ``` `isNarcissistic(512)` should return `false`. ```js assert.isFalse(isNarcissistic(512)); ``` `isNarcissistic(9)` should return `true`. ```js assert.isTrue(isNarcissistic(9)); ``` `isNarcissistic(11)` should return `false`. ```js assert.isFalse(isNarcissistic(11)); ``` `isNarcissistic(9474)` should return `true`. ```js assert.isTrue(isNarcissistic(9474)); ``` `isNarcissistic(6549)` should return `false`. ```js assert.isFalse(isNarcissistic(6549)); ``` # --seed-- ## --seed-contents-- ```js function isNarcissistic(n) { return n; } ``` # --solutions-- ```js function isNarcissistic(n) { const digits = String(n).split(''); const power = digits.length; const sum = digits.reduce((acc, d) => acc + Math.pow(Number(d), power), 0); return sum === n; } ```