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

167
Views
Using concatenated string as variable in javascript

I'm trying to use my concatenated string as a prescribed variable, I've tried eval(), window.,var instead of let, ...

Here is the code:

let selected = document.getElementById("idTempUnit");
setInterval(randomTempCelcius,1000);

let tempCelsius = Math.floor(Math.random()*50+3);

function randomTempCelcius(){
    tempCelsius = Math.floor(Math.random()*30+3);
}
let tempFahrenheit = tempCelsius * 1.8 + 32
let tempKelvin = tempCelsius + 273.15
let list = [];

let constTempObservable = new Observable((subscriber) => {
    button.onclick = function() {
        let stringtest = "temp"+selected.value
        console.log(`heey ${stringtest}`)
        if(!(list.includes(selected.value))){
            list.push(selected.value);
            addCard(selected.value, `temp${selected.value}` + "°");
        }
        subscriber.next({value0:list.indexOf(selected.value),value1:`temp${selected.value}`})
    }
});

I want to use the stringtest as the number defined above, so when I do console.log(heey ${stringtest}) I get the value generated at that moment.

about 4 years ago · Juan Pablo Isaza
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!