@Sum (JavaScript)

Sums numbers.

Defined in

@Functions (JavaScript)

Syntax

@Sum(value:...) : any
Parameter Description
value Numbers or arrays of numbers. One or more parameters are permitted.
Return value Description
any The sum of the numbers.

Usage

Scalar parameters and the members of array parameters are all summed.

Examples

(1) This example sums a progression of numbers.
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

var n = 16;
var s = new Array();
for(var i = 1; i <= n; i++) {
	s.push(i);
}
p("Sum of 1 to " + n + " = " + @Sum(s));

(2) This example sums 4 numbers.

function p(stuff) {
	print("<<<" + stuff + ">>>");
}

p("Sum of 1 to 4 = " + @Sum(1, 2, 3, 4));