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

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

0

I would consider template literals - also called backticks

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

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