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

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

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 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!