Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

166
Vistas
Is it possible to insert a variable into a string after the string has been created?

I need to mutate a strings quotes from double/single quotes to backticks, after it has already been created, so that I can add variables into the string.

I tried using replace(), but it seems as though JS does not evaluate the variable again after the replace method runs.

I am trying to understand if it is something that is possible to do, or variables can only be added to a string in JavaScript manually, and not dynamically?

Here is my code:

const variable = 9;

let strWithVar = "${variable}".replace(/"+/g, "`");

console.log(strWithVar);

The current return value is:

${abc}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Maybe do:

var world = "World";
var hello = `Hello, ${world}`;
console.log(hello)
var bob = "bob"
var helloBob = `${hello}, ${bob}`
console.log(helloBob)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda