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

133
Views
javascript single line condition

I have assignment of values below where value is based on computations for example in the code below.

If the result of

(this.dealDispositionFormFields.terminationPayment / this.metricsData["remainingObligation"])

is not a number or infinity then assign the value of this.terminationPaymentPercentageOfTotalObligation to 0

How do we address that in a one line statment in javascript ? Thanks,

image

#sample code

this.terminationPaymentPercentageOfTotalObligation 
 = ( this.dealDispositionFormFields.terminationPayment 
     / this.metricsData["remainingObligation"] );

this.terminationPaymentPercentageOfTotalObligation 
  = Math.round(
    this.metricsData["terminationPaymentPercentageOfTotalObligation"]
    * 100);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think you're looking for a conditional operator.

var x
if(condition) {
  //Do something
  x=1
} 
else {
  //Do something else 
  x=2
}

is equivalent to

const x = condition ? 1 : 2

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!