If statement

asher14
Tera Contributor

I have requirements where team A wants 250 maxlength for notes while all other teams notes will be 100..

 

I am creating a new variable in the client controller and I want to write a statement that meets the above condition.

 

I assume it would be:

c.maxLength = {

    if (team == A)

  set max length = 250;

else

set max length = 100;

}; 

1 ACCEPTED SOLUTION

Manmohan K
Tera Sage

Hi @asher14 ,

Try below code

c.maxLength = (team == 'A') ? 250 : 100;

View solution in original post

4 REPLIES 4

Manmohan K
Tera Sage

Hi @asher14 ,

Try below code

c.maxLength = (team == 'A') ? 250 : 100;

That worked! Awesome... Is that called ternary operator?

@asher14 - Yes you are right .It is a ternary operator that can be used to replace simple if-else statement

Thank you so much. Wow I'm learning every day!