reduce() method. Please explain this code

var callCount = 0;
var memoVals = [1, undefined, 8];
var actualMemoVals = [];
var recordAndUpdateMemo = function(currentMemo) {
  callCount += 1;
  actualMemoVals.push(currentMemo);
  return memoVals[callCount];
};
var finalMemo = [1, 2, 3].reduce(recordAndUpdateMemo);
actualMemoVals.push(finalMemo);


I don’t understand what is happening exactly in this code.
How actualMemoVals becomes equal to memoVals.
Pleas explain in depth all steps.
Thank you so much.

I tried console.log to see what is happening I didn’t understand.
How did we git the undefined value.