I am having an array of objects with the following structure:
const timeOptions = [
{ key: "all", value: "all", text: "All" },
{ key: "month", value: "month", text: "Month" },
{ key: "year", value: "year", text: "Year" }
];
I am creating a new object with this timeOptions being a value of a field in it. How to remove the object with key "all" in-place
while creating the object itself
const values = {
timeVal: {
field: "timestamp",
label: "Timestamp",
options: timeOptions
}
};
Code that I tried
const values = {
timeVal: {
field: "timestamp",
label: "Timestamp",
options: timeOptions.forEach((k) => delete k["key"] === "all")
}
};