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

181
Views
Can't get a string rid of quotes after being converted from array to string

I have this code:

users = [{
  "userid": "45",
  "name": "steve"
}, {
  "userid": "32",
  "name": "john"
}];

getuser = users.flatMap(user => user.userid === '32' ? user.name : []);

result = getuser.toString();

console.log(result.replaceAll("\"", ""))

fiddle here: https://jsfiddle.net/Ldob8vz2/3/

this should output simple john without the quotes but no matter what I do, I can't get rid of those quotes. Why is that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The quotes are an artifact of the way JSFiddle's console displays string values. If you open the browser's native console, you can see that console does not print the quote marks.

Also, the console implementation used by Stack Snippets also does not include the quote marks, as demonstrated here (your code without the replace):

users = [{
  "userid": "45",
  "name": "steve"
}, {
  "userid": "32",
  "name": "john"
}];

getuser = users.flatMap(user => user.userid === '32' ? user.name : []);

result = getuser.toString();

console.log(result)

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!