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

221
Views
how to put your text inside backquotes in javascript

let x = "hello"
console.log(x)
//wanted output `hello` 
//Note i have no control on x i just need to put it inside the `` so that i can make a graphql query
I have a use case where I had a query I need to put that inside the backquotes so that i can make query using graphql.

I have written the query in a separate file because it was taking a lot of space making the code less readable.

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

0

You can also use \ before the back quotes like this

let string = "\`Hello\`";
console.log(string)
about 4 years ago · Juan Pablo Isaza Report

0

Here is a functional solution to wrap any string with backticks using a Template literal (note the backticks within the string are escaped):

const x = "hello"

const wrapInBackTicks = (s) => `\`${s}\``

console.log(wrapInBackTicks(x))

about 4 years ago · Juan Pablo Isaza Report

0

This should do it:

let s="hello";
s="`"+s+"`";
console.log(s)

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!