Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

109
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!