Sum of object values #3249
Sum of object values
#3249
-
I have an object with over 20 keys and each of the values is a number. I want an expression to return the sum of those values. In javascript we would do something like |
Beta Was this translation helpful? Give feedback.
Answered by
dvd101x
Aug 13, 2024
Replies: 1 comment 1 reply
-
I don't see a way to currently get all the values of an object, or convert an object to something that can be mapped. Luckily you can import a function: math.import({ values: Object.values }) And then call your function. math.evaluate("sum(values({ a: 1, b: 2 }))") // yields 3 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
prashasti-k
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see a way to currently get all the values of an object, or convert an object to something that can be mapped.
Luckily you can import a function:
And then call your function.