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?
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)