score:1

Accepted answer
const
    initial = [50],
    transactions = [-10, 10, 10, -1, -5, -10, 5, 5, 5, 10, 10, 10, 1, -1, -2, -5, -10],
    result = [...initial, ...transactions].map((s => v => s += v)(0));

console.log(...result);

score:0

const initialAmount = [50]

const transactionAmounts = [ -10, 10, 10, -1, -5, -10, 5, 5, 5, 10, 10, 10, 1, -1, -2, -5, -10 ]

const newArray = [initialAmount[0]]
let value = initialAmount[0]
let i = 0 

do {
    value = value + transactionAmounts[i]
  newArray[i+1] = value
  i++;
}
while (i < transactionAmounts.length);
 console.log(newArray)

score:0

.as-console-wrapper {max-height: 100% !important; top: 0}

Related Query

More Query from same tag