I am trying to get the index of last non empty name in my array of objects. I tried the code below:
var myArray = [{'name':''},{'name':'b'},{'name':''}];
var last = myArray.reduce((acc, curr) => curr ? curr : acc);
console.log(myArray.lastIndexOf(last))
The log always displays 2. The output should be 1 since name == 'b' is not empty. How can I correct this code?