Recently, I encountered a challenge on Codewar. Below is my solution, but what piqued my curiosity is why both return e and return arr[i-1] yield the same outcomes.
var uniqueInOrder=function(iterable){
let arry = typeof iterable === "string" ? iterable.split('') : iterable;
return arry.filter(function(e,i,arr)
{
if(i === 0)
{
console.log(e);
return e;
}
else if(arr[i-1] !== e)
{
console.log(arr[i-1] );
return e;
//return arr[i-1];
}
});
}
uniqueInOrder("aaaabbbccdaabbbab");