Advertisement
TZinovieva

Replace Repeating Chars JS Fundamentals

Mar 8th, 2023 (edited)
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function replaceRepeatingChars(str) {
  2.     let result = '';
  3.     for (let i = 0; i < str.length; i++) {
  4.         if (str[i] !== str[i + 1]) {
  5.             result += str[i];
  6.         }
  7.     }
  8.     console.log(result);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement