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

146
Views
Functions not executing in ternary operator

I tried this in my code and also in the Chrome console and it's not doing what I want. Do you know why it's not working?

let r = 'd';
r == 'e' ? console.log('itisE') : 
r == 'd' ? console.log('itisD') : console.log('nothing');

Chrome's console prints "undefined", it doesn't execute the function calls. Neither does my code (in my code, it's for UI changes of various buttons).

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I assume that you are talking about in the google chrome browser -> developer tools and then the console inside them.

the console works in a way that it has to return/print any value to you, in this case, the let r = 'd' its not printing anything, for that reason shows undefined; becasue the console always does a Console.log() on the background.

and when you assign a value you are not really printing/returning anything, thats why you see undefined;

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!