Just building slightly on @megazoid’s question a little, I’m interpreting var b as indicating the number of values the function you need has to add together (then return) from var a.
What var b doesn’t tell me though, is what index of the var a array, it is supposed to start at. Currently, there is an assumption that the function will start at index[0] and index[2], but it’s not explicitly stated anywhere.
Hi, sorry to make incomplete explanation, by referring through the @megazoid question, it will have as below end result:
[22]
[20]
[29]
[5]
meaning that by indicate the variable b,
var b = 2, it will take a[0]+a[1],
var b = 1, it will take a[2] value,
var b = 3, it will take a[3]+a[4]+a[5],
var b = 1, it will take a[6]