MCPcopy
hub / github.com/tensorflow/tfjs-examples / sum

Function sum

cart-pole/utils.js:35–41  ·  view source on GitHub ↗
(xs)

Source from the content-addressed store, hash-verified

33 * @throws Error if `xs` is empty.
34 */
35export function sum(xs) {
36 if (xs.length === 0) {
37 throw new Error('Expected xs to be a non-empty Array.');
38 } else {
39 return xs.reduce((x, prev) => prev + x);
40 }
41}

Callers 2

setUpUIFunction · 0.90
meanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected