CC-10: Reading Objects
with Carmen Salas • 2024/10/21
Objects
too eepy to take notes
Code Challenge
Write a function named
getAllKeysthat takes in an object argument and logs all the keys in the given argument to the console.
const getAllKeys = (obj) => {
Object.keys(obj).forEach((key) => {
console.log(key);
});
};
// getAllKeys(associateInstructorAges) // will log to the console: "carmen", "itzel", "zo"Write a function named
getAllValuesthat takes in an object argument and logs the value of every key in the given argument to the console.
BONUS: 3. Write a function named sumAllValues that takes in an object argument and returns the sum of all the values of every key in the given argument.
Last updated