'can someone please tell me why is "previousValue" here in the code is "array type"?

// logic to console duplicate in a new array
let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd'] let myArrayWithNoDuplicates = myArray.reduce(function (previousValue, currentValue) { if (previousValue.indexOf(currentValue) === -1) { previousValue.push(currentValue) } return previousValue }, [])

  console.log(myArrayWithNoDuplicates)


Solution 1:[1]

previousValue is the previous value of your accumulator. Your accumulator is [] an array so previousValue has to be array

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tirth