for…of명령문이란? 반복가능한 객체( Array, Map, Set, String, TypedArray, arguments 등등)에 대해서 반복하고 각 개별 속성값에 대해 실행되는 문이 있는 사용자 정의 반복 후크를 호출하는 루프를 생성

let imcomes = [3500,3700, 4000]
let total = 0

for(const income of imcomes){
  console.log(income)// 3500, 3700, 4000 
  total += income // income값을 더해 합산
}
console.log(total)// 11200(합산 값)

let fullName = 'Dylan Coding God Israet'
for (const char of fullName){
  console.log(char)
}

imcomes에 있는 3500, 3700, 4000을 각각 for 문에서 들고 와 income에 넣고 출력한 후 출력한 값을 더한다.

문제

student에 있는 Object 3개 출력하기 조건: template literal 사용하기

//challenge
const students = [
  { name: "John", city: "New York" },
  { name: "Peter", city: "Paris" },
  { name: "Sam", city: "Sidney" }
];

for (const a of students) {
  const { name, city } = a;
  console.log(`${name} lives in ${city}`);//[template literal](<https://poiemaweb.com/es6-template-literals>) 사용
}