Using Axios in my Vue app, I am consuming a JSON file. The field "country" contains trailing commas which are creating issues.
Here is the structure of the JSON:
"country": "spain,france,"
....
"country": "spain,belgium,"
...
In my JavaScript code, I successfully replaced 'france' with 'XXXXXX', as shown below:
const arr = this.countries;
const newArr = arr.map((countries) => {
if (countries === "france") {
return "XXXXXX";
}
// return countries;
});
console.log("commas " + newArr);
I have tried different approaches to remove the trailing commas without success. Can someone offer assistance on how to achieve this?