Although the code below is incorrect, it reflects my intention. Can this be achieved? I am looking to update the original array so that all orderno values are formatted as 000.0.000.00000.0.
let cars= [
{orderno: "5766302385925", make: "Alfa", dealership: "NA"},
{orderno: "4663873261390", make: "Merc", dealership: "NA"},
{orderno: "8458821291579" , make: "BMW", dealership: "EU"},
{orderno: "3376768687480", make: "Ford", dealership: "NA"},
{orderno: "5186132840921", make: "Buick", dealership: "EU"},
];
function addOrderDot() {
for (var i=0; i<cars.length; i++) {
cars.orderno[i].splice(2,0,'.')
cars.orderno[i].splice(3,0,'.')
cars.orderno[i].splice(6,0,'.')
cars.orderno[i].splice(11,0,'.')
}
}
Desired output array after applying the function:
let cars= [
{orderno: "576.6.302.38592.5", make: "Alfa", dealership: "NA"},
{orderno: "466.3.873.26139.0", make: "Merc", dealership: "NA"},
{orderno: "845.8.821.29157.9" , make: "BMW", dealership: "EU"},
{orderno: "337.6.768.68748.0", make: "Ford", dealership: "NA"},
{orderno: "518.6.132.84092.1", make: "Buick", dealership: "EU"},
];