Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidystephenson/42c4e4d1451f73b35da2c7c9611cc784 to your computer and use it in GitHub Desktop.
Save davidystephenson/42c4e4d1451f73b35da2c7c9611cc784 to your computer and use it in GitHub Desktop.
// 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