Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rewrite the following using promises instead of callbacks.
- const f = (firstName, callback) => {
- setTimeout(() => {
- if (!firstName) return callback(new Error('firstName is required'))
- const fullName = `${firstName} Smith`
- return callback(fullName)
- }, 2000)
- }
- f('Andrew', console.log)
- f(null, console.log)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement