- Open your command-line application and navigate to your workspace.
- Create a new folder named 3-08-simulating-finally.
- Copy or create an index.html that loads and runs a main function from main.js.
- Create a main.js file with a main function that logs out messages for before and after promise creation:
export function main() { console.log('Before promise created'); console.log('After promise created'); }
- Create a function named addBoosters that throws an error if its first parameter is false:
function addBoosters(shouldFail) { if (shouldFail) { throw new Error('Unable to add Boosters'); } return { boosters: [{ count: 2, fuelType: 'solid' }, { count: 1, fuelType: 'liquid' }] }; }
- Use Promise.resolve to pass a Boolean ...