Given below is an object stored in variable nestedObject. Inside this object, you can see a property with keyname countries with 1 object value (switzerland). I want to create a function with 4 arguments: object,countryName, capital, population which adds a new key-value pair inside countries object and return the value of a newly inserted key. The key being countryName and value, an object with properties as shown in the example.
I want to Create a new function to add country with the name, capital, and population as parameters ---Then Call the function with given parameter values ---Return the result in the output variable
Given below is the format of the object which will be passed as the argument.
speakers: [{ name: "Elie" }, { name: "Tim" }, { name: "Matt" }],
data: {
continents: {
europe: {
countries: {
switzerland: {
capital: "Bern",
population: 38000000
}
}
}
},
languages: {
spanish: {
hello: "Hola"
},
french: {
hello: "Bonjour"
}
}
}
}```