Created
May 12, 2023 17:08
-
-
Save suhailgupta03/2cb7f21a16ba4933cce5b255198cbd03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const person = { | |
firstName: "..", | |
lastName: '..', | |
age: 30 | |
} | |
console.log(person['age']); | |
// We want to modify the age | |
for(var nameOfKey in person) { | |
if(nameOfKey == "age") { // If the name of key is age | |
// If the key is age, | |
// then change the value of | |
// this key | |
person[nameOfKey] = 35; | |
} | |
} | |
console.log(person['age']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment