Advertisement
viligen

wordsToUppercase

May 19th, 2022
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function myFunc(input) {
  2.     let output = input.replace(/[^A-Za-z0-9\s]+/gm, ' ')
  3.     let result = []
  4.     for (let w of output.split(' ')){
  5.         if (w === '' || w === ' '){continue}
  6.         result.push(w.toUpperCase())
  7.     }
  8.     console.log(result.join(', '))
  9.  
  10. }
  11.  
  12.  
  13.  
  14. myFunc('Functions in JS can be nested, i.e. hold other functions')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement