โณ
Delay Function
Delay Function์ฌ์ ๋น๋๊ธฐ +10pts
Problem
Write a function that returns a promise that resolves after a specified delay.
Examples
Input:
await delay(1000)Output:
undefined (1์ด ํ)Explanation
์ด ๋ฌธ์ ๋ **Promise**์ **setTimeout**์ ๊ฒฐํฉํ์ฌ ๋น๋๊ธฐ ์ง์ฐ์ ๊ตฌํํ๋ ๋ฐฉ๋ฒ์ ํ์ตํฉ๋๋ค. **Promise๋?** ๋น๋๊ธฐ ์์ ์ ์๋ฃ(๋๋ ์คํจ)๋ฅผ ๋ํ๋ด๋ ๊ฐ์ฒด์ ๋๋ค. pending, fulfilled, rejected ์ธ ๊ฐ์ง ์ํ๊ฐ ์์ต๋๋ค. **Promise ์์ฑ์** `new Promise((resolve, reject) => { ... })` - resolve: ์ฑ๊ณต ์ ํธ์ถ - reject: ์คํจ ์ ํธ์ถ **setTimeout๊ณผ Promise ์ฐ๊ฒฐ** ```javascript new Pr...
View detailed explanation โKey Concepts
Promise ์์ฑ setTimeout resolve ํจ์ ๋น๋๊ธฐ ์ง์ฐ
Time: O(1) Space: O(1)
solution.js
Ctrl + Enter
Run tests to see results here.