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

215
Views
How to automatically turn variable name to a string value?

I want to implement a reusable helper function which can change the name of a variable to string value. For example, I have some parameters, the function will print which one is empty:

paramsHandler(name, address, mobileNum, ...){
  if(!name){
    console.log("name cannot be empty");
  }
  if(!address){
    console.log("address cannot be empty");
  }  
  if(!mobileNum){
    console.log("mobileNum cannot be empty");
  }
  ...
}

Now, I want to make it generalized, something like below, where key should be the string of the parameter name.

paramsHandler(...params){
  for(const key of params){
      if(!key){
         console.log("key cannot be empty");
      }
  }
}

Do anyone knows how could I do this?

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!