** Silver Challenge: Promise Practice
As I’m working through the challenges, posting my solutions - any comments/suggestions welcome.
resources/react-resources/code-cafe-resources/demos/promiseDemo.js
const getData = () => {
console.log("getData Running");
- return Promise.resolve("yay!");
+ return Promise.reject("error!");
};
Expected:
top
getDataRunning
error error
end
got:
top
getData Running
end
error error!
My original thought was that javascript would report the error as soon as possible (interrupting synchronous work), but given the output, my new thinking is that as Promise.reject
is asynchronous work (just like Promise.resolve
, then it make sense that error error!
gets printed at the end.