Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. //Practice 1
  2. const testNum = (n) => {
  3. return new Promise((resolve, reject) => {
  4. if (n > 10) {
  5. return Promise.resolve(`${n} is greater than 10, success!`);
  6. }
  7. }
  8. return Promise.reject(`${n} is less than 10, error!`);
  9. }
  10.  
  11.  
  12. //Practice 2
  13. const makeAllCaps = (array) => {
  14. return new Promise((resolve, reject) => {
  15. return array.map(word => {
  16. if (typeof word === 'string') {
  17. resolve(word.toUpperCase());
  18. }
  19. reject('No, the array you passed in contained an element that was not a string!');
  20. }
  21. }
  22. }
  23.  
  24. const sortWords = (array) => {
  25. return new Promise((resolve) => {
  26. resolve(array.sort());
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement