Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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'));
Comment

remove the duplicate character in string js

function removeDuplicate(str, letSingleChar = false)  {
    let string = str;
    for (element of string) {
        const re = new RegExp(element, 'g');
        if (string.match(re)?.length > 1) {
          if (letSingleChar == true) {
            string = [...new Set(string.split(''))].join('');
          } else 
            string = string.replace(re, '');
        }
    }
    return string;
} 

console.log(removeDuplicate("Hello World", true)) // Helo Wrd
console.log(removeDuplicate("Hello World", false )) // He Wrd
Comment

remove repeated characters from a string in javascript

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

unrepeated("hello"); //➞ "helo"
unrepeated("aaaaabbbbbb"); //➞ "ab"
unrepeated("11112222223333!!!??"); //➞ "123!?"
Comment

remove duplicate values from string in javascript

const names = ['John', 'Paul', 'George', 'Ringo', 'John'];

let unique = [...new Set(names)];
console.log(unique); 
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to create list of years js 
Javascript :: vue js required props 
Javascript :: discord.js send embed 
Javascript :: merge data to json js 
Javascript :: javascript display 2 number after comma 
Javascript :: comparsion javascript 
Javascript :: sort array of objects javascript by date 
Javascript :: Get React Native View width and height 
Javascript :: how to check checked checkbox in jquery 
Javascript :: nuxt lang 
Javascript :: nodejs json beautify 
Javascript :: jquery remove option from dropdown 
Javascript :: react form reload page 
Javascript :: ... unicode 
Javascript :: jquery index of element 
Javascript :: merge two objects javascript 
Javascript :: javascript validate date 
Javascript :: run nextjs in separate port 
Javascript :: jquery iframe use from js style 
Javascript :: how to send header in axios 
Javascript :: how to clear local storage 
Javascript :: dart list files in directory 
Javascript :: react router refresh page 
Javascript :: install node js 14 
Javascript :: check if type is blob javascript 
Javascript :: jquery migrate 
Javascript :: fibonacci sums javascript 
Javascript :: how get first option in select in vue js 
Javascript :: react 404 page not found 
Javascript :: how to make a show password button 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =