Skip to content

Math helpers

add multiply avg random ceil round divide subtract floor sum

add

Return the sum of a plus b.

Parameters:

  • a {Number}
  • b {Number}

Returns {Number}

avg

Returns the average of all numbers in the given array.

Parameters:

  • array {Array}: Array of numbers to add up.

Returns {Number}

Example:

{{avg "[1, 2, 3, 4, 5]"}}
<!-- results in: '3' -->

ceil

Get the Math.ceil() of the given value.

Parameters:

  • value {Number}
  • returns

divide

Divide a by b

Parameters:

  • a {Number}: numerator
  • b {Number}: denominator

floor

Get the Math.floor() of the given value.

Parameters:

  • value {Number}
  • returns

multiply

Return the product of a times b.

Parameters:

  • a {Number}: factor
  • b {Number}: multiplier

Returns {Number}

random

Generate a random number between two values

Parameters:

  • min {Number}
  • max {Number}

Returns {Number}

round

Round a number to the nearest integer.

Parameters:

  • number {Number}

Returns {Number}

subtract

Return the product of a minus b.

Parameters:

  • a {Number}
  • b {Number}

Returns {Number}

sum

Returns the sum of all numbers in the given array.

Parameters:

  • array {Array}: Array of numbers

Returns {Number}

Example:

{{sum "[1, 2, 3, 4, 5]"}}
<!-- results in: '15' -->