My problem can be reduced to this trivial (or so it seemed) bit of code
var myArray = [1,2];
function addOnetoArrayElement(element){
element +=1;
console.log(element); // Returns 3
}
addOnetoArrayElement(myArray[1]);
console.log(myArray[1]); // Returns 2
I find in fascinating that one can do all sorts of operations on arrays like map, reduce, push to an array but no reference at all to doing simple arithmetic operations of elements of an array. Never mind all that stuff about hoisting,scope, passing by value and reference. I'm sure that maybe someday I'll know enough to contribute to that discourse. What must I do to make myArray[1] = 3?