I am looking for a way to create a new array without modifying the original one. Currently, there is a function that adds a new object to an existing array, but I need a different method to achieve this. Can someone suggest a solution?
const arr = [
{
"name":"BMW",
"price":"55 000",
"country":"Germany",
"certificate":"yes"
},
{
"name":"Mitsubishi",
"price":"93 000",
"constructor":"Bar John",
"door":"3",
"country":"Japan",
},
{
"name":"TOYOTA",
"price":"48 000",
"max_people":"7",
"country":"Japan",
"certificate":"yes"
},
{
"name":"Volkswagen",
"price":"36 000",
"constructor":"Pier Sun",
"country":"Germany",
"certificate":"no"
},
];
function pushArr (arr, item){
arr.push(item);
}
let Cars = pushArr(arr,{
"name":"Audi",
"price":"89 000",
"constructor":"Hubert Trumpius",
"country":"Germany",
"certificate":"yes"
});
console.log(arr);