Created
May 17, 2025 17:11
-
-
Save davidystephenson/42c4e4d1451f73b35da2c7c9611cc784 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
// 8. Write a program to create an array of objects "employees" with properties "name", "age", and "city" and set their respective values to | |
// "John", 30, "New York", "Thomas", 40, "Chicago", "Lily", 35, "San Francisco". Print the name, age, and city of each employee. | |
// Print the name, age, and city of each employee using for..of loop. | |
var employees = [ | |
{ name: 'John', age: 30, city: 'New York' }, | |
{ name: 'Thomas', age: 40, city: 'Chicago' }, | |
{ name: 'Lily', age: 35, city: 'San Francisco' } | |
] | |
for (var employee of employees) { | |
console.log(employee.name) | |
console.log(employee.age) | |
console.log(employee.city) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment