I have an object which basically consists of some of the names of cars. I just want to delete the key of that object based on user input.
For instance:
let cars = {
car1: 'BMW',
car2: 'Lambo',
car3: 'Mercedes'
};
const deleteCar = (car) => {
delete cars.car;
}
deleteCar('car1');
console.log(cars);
As you can see, it doesn't actually delete the key from the object. How can I do this?