function lastDigit(str1, str2) {
const numArr = Math.pow(+str1, +str2).toString().split('');
return +numArr[numArr.length-1];
}
console.log(lastDigit('4', '1')); // 4
console.log(lastDigit('4', '2')); // 6
console.log(lastDigit('10', '10000000000')); // 0
console.log(lastDigit('10', '10000000000')); // 0