I have tried to look at many things for this but I simply cannot figure out how to make it work. I am very new to coding in general, so it may be a lack of understanding! Simply put, I have a an array with a set amount of elements, and I want to be able to sum up consecutive elements, starting from a specific index and ending at specific index.
const array = [1,2,3,4,5,6]
I want to be able to sum index 1 and 3, which in this case would be 2+4 =6.
Is there a way to use array.filter() or just use a function where I sum based on the array.indexof()?