Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

49
Views
Nested conditional ternary operator in javascript

I have the below code, where idName is selected based on id1 or id2.

const getValues = async ({ id1, id2, ...request}) => {
   const id = id1 || id2;
   const idName = id1? 'uid' : 'sid';
 };

Now, I add another parameter "id3" and which needs to get selected when id1 is not passed in as input. But the below code throws an error. Any leads would be appreciated.

const getValues = async ({ id1, id2, id3, ...request}) => {
   const id = id1 || id2 || id3;
   const idName = id1 ? id3 ? ('uid' : 'sid') ? (id3);
 };
7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

const getValues = async ({ id1, id2, id3, ...request}) => {
   const id = id1 || id2 || id3;
   const idName = id1? 'uid': id3? 'something-for-id3': 'sid'
};
7 months 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 job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.