Answers for "remove repeated characters from a string in javascript"

1

javascript remove duplicate letters in a string

function removeDuplicateCharacters(string) {
  return string
    .split('')
    .filter(function(item, pos, self) {
      return self.indexOf(item) == pos;
    })
    .join('');
}
console.log(removeDuplicateCharacters('baraban'));
Posted by: Guest on February-29-2020
1

remove repeated characters from a string in javascript

const unrepeated = (str) => [...new Set(str)].join('');

unrepeated("hello"); //➞ "helo"
unrepeated("aaaaabbbbbb"); //➞ "ab"
unrepeated("11112222223333!!!??"); //➞ "123!?"
Posted by: Guest on April-25-2021
0

remove duplicates strig javascript

const arr = [1, 2, [3, 4]];

// To flat single level array
arr.flat();
// is equivalent to
arr.reduce((acc, val) => acc.concat(val), []);
// [1, 2, 3, 4]

// or with decomposition syntax
const flattened = arr => [].concat(...arr);
Posted by: Guest on March-26-2021

Code answers related to "remove repeated characters from a string in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language