The function returns the last digit of the number, but if the number is too large then infinity, how to handle the number so that infinity does not return?
var lastDigit = function(str1, str2){ var result = Math.pow(+str1,+str2).toString().split(''); var elem = +result[result.length - 1]; console.log(elem); }; lastDigit("4", "1"); // 4 => 4 lastDigit("4", "2"); // 16 => 6 lastDigit("9", "7"); // 4782969 => 9 lastDigit("10","10000000000"); //=> 0
str1into 10 squares (probably it wasn’t multiplied by a long time?) - avp