Any help to get me through an assignment I am currently stuck on would be greatly appreciated. I am aware that the title of this post might seem confusing, so I will do my best to elaborate. Here is the assignment in question:
The task is to create a function named getValues. This function should: take one parameter, an object return an array containing all the values within the object. Additionally, it should return an empty array if no values are present.
The function should display the values of {name: "Rob", age: 25}
I managed to write the function successfully. Here it is:
var name = ("Rob");
var age = (25);
var getValues = function() {
return [name, age];
};
The issue arises when I attempt to write a function returning an empty array, as it interferes with the prior function.
Is there a way to modify this code so that both functions can coexist successfully? Can this function be altered to perform both tasks effectively? I am new to programming and any guidance would be greatly appreciated.