I want to remove comma in the last element in Vue. But I dont know how to do that because the index of the last element is unknown.
<td v-if="category.sub_category.length > 0">
<template v-for="cat in category.sub_category">
{{ addComma(cat.subcategory_name) }}
</template>
</td>
addComma(subCat) {
let elements = [];
elements.push(subCat);
console.log(elements);
if (elements != ""){
elements += ", ";
}
return elements;
},
And this is the result of console.log(elements)
above.
And this is the result of all code above