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

220
Vistas
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 Respuestas
Responde la pregunta

0

You can also use \ before the back quotes like this

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

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 Denunciar

0

This should do it:

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

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