fungsi pengembalian karakter terakhir

//function to return last character in word 
function lastChar(number){
    const str = number
    console.log(str.charAt(str.length-1));
}

lastChar('sun'); //n
Shy Skipper