add

Modified on Thu, 9 Jul at 10:48 AM

add

TABLE OF CONTENTS

Mathematical addition of two arguments

Definition

number add(number $left, number $right)

Returns $left + $right.

Parameters

number $left

The left argument of addition.

number $right

The right argument of addition.

Returns

number

A number equal to the value of the sum of the two parameters.

Examples

Transformation
{
  sum: add(`3`,`2`),
  sum2: add(`3`,`-2`),
  boolSum: add(`true`,`false`),
  boolSum2: add(`true`,`10`),
  numStringSum: add('3.1', '2.9'),
  nullSum: add(`null`,`null`),     // Error
  textSum: add('a', 'b'),           // Error
  arraySum: add(`[]`,`[]`),        // Error
  objectSum: add(`{}`,`{}`)        // Error
}
Result
{
  "sum": 5,
  "sum2": 1,
  "boolSum": 1,
  "boolSum2": 11,
  "numStringSum": 6
}

Remarks

boolean arguments are valid as well and implicitly converted to their integer values. Same holds for string arguments that follow a number format. However, it is recommended to call the function with number parameters.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article