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

202
Views
Change a variable's value through ES6 Interpolation

Consider this code

           switch (rackID) {
                case 1:
                    rack_data.rack1.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                case 2:
                    rack_data.rack2.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                case 3:
                    rack_data.rack3.temp = [temp1, temp2, temp3, temp4, temp5, temp6];
                    break;
                 

Notice how this code is repetitive whereas using this code would be useful rack_data.rack${rackID}.temp = [temp1, temp2, temp3, temp4, temp5, temp6] could be better, but this isn't allowed.

I know eval exists, but everyone says that it poses security issues so I'm trying to look for a alternative.

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!