Home > Software engineering >  Replace single quote ( ' ) from each record in list JS
Replace single quote ( ' ) from each record in list JS

Time:06-29

so I have a list like this:

[
  '32350.0*51355000*9999',
  '6604.5*23680102*9999', 
  '14500.0*23680202*9999' 
]

And I want to look like this:

[
  32350*51355000*9999,
  6604*23680102*9999, 
  14500*23680202*9999 
]

My problem is, I try every way i know to replace the single quote but, nothing work, so far so god, I got this code:

for (var i = 0; i < impuestos.length; i  ) {
    formateo = impuestos[i]
    impuestos[i] = formateo.replaceAll(/'/g, "")
}

console.log(impuestos);

But I still getting the same result, any idea of how can i do it? Thank you very much to all!

CodePudding user response:

The single quotes denote the type of data that you're representing... You're representing a String (a text element), so you get '' around the elements in the console.

That's just the way it is.

If you were to render them, say on a webpage, they wouldn't have the quotes around them, if that's what's concerning you?

  • Related