I need to write a function that takes in an object and returns an array with this object's property values.
Ex.:
var obj = {
name: "Joao",
age: 27,
country: "USA"
};
The function should return an array like this:
var array = ["John", 27, "USA"];
I can't use Object.values().
That's how my last attempt looks like:
function returnValues(obj) {
for (var key in obj) {
return obj[key];
}
It does not return an array with the values. Can anyone help me?
I can't use Object.values().yes you can - developer.mozilla.org/en/docs/Web/JavaScript/Reference/…