Explore
<div v-for="todo in sortedArray">
<b-button block pill variant="outline-info" id="fetchButtonGap" v-model:value="todo.items[0].arrivalTime">
{{fromMilTime(todo.items[0].arrivalTime)}}
</b-button>
</div>
Code Snippet
sortedArray: function() {
function compare(a, b) {
var standardTimeA = moment(a.items[0].arrivalTime, "HHmm").format("HH:mm A");
var standardTimeB = moment(b.items[0].arrivalTime, "HHmm").format("HH:mm A");
if(standardTimeA = standardTimeB){
let unique = [...new Set(standardTimeA,standardTimeB)];
}
if (standardTimeA < standardTimeB)
return -1;
if (standardTimeA > standardTimeB)
return 1;
return -1;
}
return this.allbookings.sort(compare);
}
fromMilTime: function(todo){
var militarytime = todo;
var standardTimeB = moment(militarytime, "HHmm").format("hh:mm A");
return standardTimeB;
},
If the items.arrivalTime
includes multiple times such as 11:00 AM , 12:00 PM , 09:00 AM and 11:00 AM. Initially, it arranges the times using the sortedArray()
method to display them as 09:00 AM, 11:00 AM , 11:00 AM and 12:00 PM.
Is there a method to eliminate duplicate values after executing the sortedArray()
function? The desired outcome should be 09:00 AM, 11:00 AM and 12:00 PM.