I would suggest creating allSaves
directly as an Array.map()
instead of using a traditional loop block. Also note that your iterator variable L
should be a let
instead of a var
so that it is scoped appropriately.
function savingList(principal, interestRate, time, compoundNumber) {
return [...new Array(3)].map(saveIteration =>
[principal, interestRate, time, compoundNumber]
)
The phrase [...new Array(i)]
is just a way of getting a map-able array of length i
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…