On a website, I have a set of entry fields for users to insert a selection of values. I currently have some JavaScript that finds the highest value that was entered into the array, and stores the index position of that particular value in a variable named HighValPos.
This is the code for it:
var HighValPos = inputtedVals.reduce((highestInd, TheValue, TheValueInd) => {
return TheValue > inputtedVals[highestInd] ? TheValueInd : highestInd;
}, 0);
The problem I have is fundamentally a syntax issue; what I would like to do is only apply this .reduce() logic to array elements whose index value is between these two variables:
var firstEl = 0
var lastEl = 6
What can I try next?