var num=1234 My answer should be 4 how do i do that? I tried using "split" and "toString" but I don't know how to use it.
var num=1234 My answer should be 4 how do i do that? I tried using "split" and "toString" but I don't know how to use it.
Try this
var num = 1234; var stringNum = num.toString(); var arrayNum = stringNum.split(""); var lastNumber = arrayNum[arrayNum.length-1];