const getNarcissisticNumbers = (n) => {
const max = Math.pow(10, n)
const min = Math.pow(10, n - 1)
const arr = []
for (let i = min; i<= max; i++) {
let list = []
for(let number = 0; number < i.toString().length; number++) {
list.push(i.toString().charAt(number))
}
let total = 0
list.forEach(num => {
total += Math.pow(num, n)
})
i === total && arr.push(i)
}
console.log(arr)
}
getNarcissisticNumbers(5)