Advertisement
Naralex

03. Santa's Reindeer_v2

Nov 21st, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(str) {
  2.     let text=str.split(' ');
  3.     let name=[];
  4.  
  5.     text = text.map((a) => {
  6.         if ((a.startsWith('*') && a.endsWith('*')) &&
  7.             (a[1] === a[1].toUpperCase() && a.substr(2) === a.substr(2).toLowerCase())){
  8.             name.push(a);}
  9.         else {return a;}});
  10.  
  11.     console.log(name.join(', '));
  12.     console.log('*'.repeat(20));
  13.     console.log(text.filter(arr => arr).join(' '));
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement