test2.js 671 Bytes
const delay = () => {
    const randomDelay = Math.floor(Math.random() * 4) * 100
    return new Promise(resolve => setTimeout(resolve, randomDelay))
  }
  
const loop = async (list) => {
console.log("시작")
const promises = list.map(async data => {
    return await delay()
    .then(() => data)
})

const results = await Promise.all(promises)
results.forEach(data => console.log(data))
console.log("끝")
}

const list = [1, 2, 3, 4, 5, 6, 7]
loop(list)


// const result = async (list) => {
//     for (const data of list) {
//       await delay()
//         .then(() => console.log(data))
//     }
//   }
  
//   const list = [1, 2, 3, 4, 5, 6, 7]
//   result(list)