Advertisement
shady_obeyd

08.Extract Capital-Case Words

Nov 14th, 2017
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function extractCapitalCaseWords(text) {
  2.     let arr = text[0].split(/[^A-Za-z]+/).filter(w => w.length > 0);
  3.  
  4.     let result = [];
  5.  
  6.     for(let i = 0; i < arr.length; i++){
  7.         let currentWord = arr[i];
  8.         let wordInCapitals = currentWord.toUpperCase();
  9.  
  10.         if(currentWord == wordInCapitals){
  11.             result.push(currentWord);
  12.         }
  13.     }
  14.  
  15.     console.log(result.join(', '));
  16. }
  17.  
  18. let text = ['We start by HTML, CSS, JavaScript, JSON and REST.\n' +
  19. 'Later we touch some PHP, MySQL and SQL.\n' +
  20. 'Later we play with C#, EF, SQL Server and ASP.NET MVC.\n' +
  21. 'Finally, we touch some Java, Hibernate and Spring.MVC.\n'];
  22.  
  23. extractCapitalCaseWords(text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement