Суммирование умножения цифр с соответствующей им степенью десяти:
т.е.: 123 = 100 + 20 + 3 = 1 * 100 + 2 + 10 + 3 * 1 = 1 * (10 ^ 2) + 2 * (10 ^ 1) + 3 * (10 ^ 0)
function atoi(array) {
// use exp as (length - i), other option would be to reverse the array.
// multiply a[i] * 10^(exp) and sum
let sum = 0;
for (let i = 0; i < array.length; i++) {
let exp = array.length-(i+1);
let value = array[i] * Math.pow(10,exp);
sum+=value;
}
return sum;
}