JSFiddle - React, Tailwind, and code Playground
JavaScript
const L = 2020,
R = 4040
let cnt = 0
for (let i = L; i <= R; i++) if (i === String(i).split('').map(el => Math.pow(el, el)).reduce((acc, cur) => acc + cur)) cnt++
console.log(cnt)
const L = 2020,
R = 4040
let cnt = 0
for (let i = L; i <= R; i++) if (i === String(i).split('').map(el => Math.pow(el, el)).reduce((acc, cur) => acc + cur)) cnt++
console.log(cnt)