generated from CodecoolArchive/async-workshop-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask9.js
More file actions
27 lines (20 loc) · 942 Bytes
/
task9.js
File metadata and controls
27 lines (20 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { openSchrodringerBox } from "./promises.js";
/*
- We have a box and a cat in it. We don't know which cat.
- If we open the box two outcome is possible, the cat is alive and we got back the name of the cat,
or the cat is dead unfortunately.
- Detect the cat's state log "Alive:" with the cat's name to the console if the cat is alive.
- Log the "Dead:" and the error message, if the cat is dead.
- Use the openSchrodringerBox() function.
It has no paramter, but returns a Promise. A promise fulfills with the cat name in 50% of
calls. It can also rejects with a JS Error in 50%.
syntax: openSchrordringer(): Promise<string>
- Use the then syntax.
Goal: Try out Promise rejected state and error handling with catch?
Questions:
- When the will be the then's callback and when the catch callback will be called?
- How we can access the error message.
*/
const task = async () => {
}
task()