Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Practice 1
- const testNum = (n) => {
- return new Promise((resolve, reject) => {
- if (n > 10) {
- return Promise.resolve(`${n} is greater than 10, success!`);
- }
- }
- return Promise.reject(`${n} is less than 10, error!`);
- }
- //Practice 2
- const makeAllCaps = (array) => {
- return new Promise((resolve, reject) => {
- return array.map(word => {
- if (typeof word === 'string') {
- resolve(word.toUpperCase());
- }
- reject('No, the array you passed in contained an element that was not a string!');
- }
- }
- }
- const sortWords = (array) => {
- return new Promise((resolve) => {
- resolve(array.sort());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement