Convert to String to get sum of the cubes of its digits
let str = ( N ) . toString ( ) ; let sum = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { let val = ( str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; sum += val * val * val ; }