Advertisement
kstoyanov

05. Replace Repeating Chars

Jul 17th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const characters = args.split('');
  3.   const arrCH = [];
  4.  
  5.   characters.forEach((ch, index) => {
  6.     if (ch !== characters[index + 1]) {
  7.       arrCH.push(ch);
  8.     }
  9.   });
  10.  
  11.  
  12.   console.log(arrCH.join(''));
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement