Ad
  • Custom User Avatar

    think of ...vals as of the 'rest' arg which is a collection of everything what you call the function with after the positional arguments. In this concrete example calling scoreTest with (str, right, omit, wrong) will map to str -> str and vals -> [right, omit, wrong]. V arg of the reduce's callback is a value from your str collection (an answer to the question in the test), so vals[v] will return you the number of points for right, omit or wrong answer and [1,1,-1] array simply gives you a sign you should use with this value. '() => expressions' is a way to define lambda in ES6