Skip to main content
100%

Gist fefe34600946bdbccd93fc2b6728aefe

✓ Published0🌍 Public
MMistyBlunch
Last edited Jun 12, 2019
Created on Jun 12, 2019

This example shows a JavaScript promise used to model a conditional request for a new phone. The code defines a `Promise` constructor that resolves with a phone object when a boolean flag `isMonHappy` is true, and rejects with an error otherwise. The `askMon` function calls the promise, chaining `.then()` to log the resolved phone details and `.catch()` to log the rejection message. The demonstration relies solely on native promise syntax and `console.log` for output, with no external libraries or rendering.

AI-generated description

Similar vizzes