Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
Characters used in string?

I found many question about counting characters used in a string and solutions but how can I get all character used in string? Im new to JavaScript, im do not know to output this

for example "English-Language" to "E,n,g,l,i,s,h,-,L,a,u,e" or "Javascript String" to "J,a,v,s,c,r,i,p,t, ,S,n,g"

Thank you..

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Very simple with Set: (just cast it back to an array)

console.log([...new Set("English-Language")]);
console.log([...new Set("Javascript String")]);

And if you want it as a single string, do this:

console.log([...new Set("English-Language")].join(","));
console.log([...new Set("Javascript String")].join(","));

about 4 years ago · Juan Pablo Isaza Relatório

0

You can use the split function and the Set class to achieve this like so.

new Set("Javascript String".split(''))

The split('') part splits the string using an empty string as the seperator, so it just returns an array of all the characters. If you make a set from that array, it'll remove the duplicates. You can even pass the string directly to the Set constructor. If you want it as an array, just use Array.from.

about 4 years ago · Juan Pablo Isaza Relatório

0

you can simply use str.split("");

const str = 'English-Language';
str.split("");

Let me know if you face any future issue.

or Second option is

console.log([...new Set("English-Language")]);

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda