File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Document</ title >
7+ </ head >
8+
9+ < body >
10+ < script >
11+ var x = 0
12+ </ script >
13+ < script >
14+ // You order 🍅 tomato soup
15+ // Meanwhile you continue your convo with a friend
16+ // RESOLVED - 🍲 your server brings you soup
17+ // REJECTED - ❌ No soup today.
18+
19+ // setTimeout(() => {
20+ // console.log("soup")
21+ // }, 2000)
22+
23+ const orderSooup = ( ) => console . log ( "soup" )
24+
25+ console . log ( "You start the convo with your friend 👳♂️!" )
26+ setTimeout ( orderSooup , 2000 )
27+ console . log ( "Still speaking" )
28+
29+ const promise1 = new Promise ( ( resolve , reject ) => {
30+ setTimeout ( ( ) => {
31+ isReady = [ true , false ] [ Math . floor ( Math . random ( ) * 2 ) ]
32+ isReady ? resolve ( "✅soup is ready 🍲" ) : reject ( "❌No soup today 🍲" )
33+ } , 3000 )
34+ } )
35+
36+ // promise1.then((message) => console.log(message)).catch((error) => console.error(error))
37+ console . log ( promise1 . then ( ( success ) => console . log ( { success } ) ) . catch ( ( error ) => console . log ( { error } ) ) )
38+ </ script >
39+ </ body >
40+ </ html >
You can’t perform that action at this time.
0 commit comments