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

130
Vistas
JavaScript - Concatenate a value within variable

I know that this is somewhat, very basic question, but.. I have to create a cypress element, for which I have to concatenate a value between variables.

Like I have this value

const value = "100 - 299"

and I have to print a value within a string, i.e.

cy.get('[data-value="100 - 299"]')

I am trying everything but unable to do so. Can someone help me on this?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

I would consider template literals - also called backticks

cy.get(`[data-value="${value}"]`)
about 4 years ago · Juan Pablo Isaza Denunciar

0

You could consider concatenation.

const value = "100 - 299"

cy.get('[data-value="' + value + '"]')

Or template literals ( check compatability: https://caniuse.com/template-literals )

cy.get(`[data-value="${value}"]`)

Or pre-concatenation:

const value = "100 - 299"
const fullstring = '[data-value="' + value + '"]'
cy.get(fullstring)
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