I have an object of states like below code. I want to add many states and cities to it
const stateObject = {
missouri: ["springfield", "rolla"],
nevada: ["carlin", "vegas"],
}
const addState = (...state) => {
return stateObject.push(state);
}
I did not get answer.
- How can I create a function to add new state to the object using the spread operator?
- How can I create a function to add list of new city to one of state using the spread operator?
any solution would be much appreciated