How do you use if statement in for in loop to get value associated with the key?

#1

How do you use if statement in for in loop to get value associated with the key ?

1 Like
#2

Maybe something like this?

const person = { name: 'Kevin', school: 'ACA', job: 'Web Developer' };

for (key in person) {
  if (key === 'name') {
    console.log(`${person[key]} is my name!`);
  }
}
2 Likes
#3

Thanks for your answer!