Skip to content

Sum of object values #3249

Closed Answered by dvd101x
prashasti-k asked this question in Q&A
Aug 12, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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

Replies: 1 comment 1 reply

Comment options

dvd101x
Aug 13, 2024
Collaborator Sponsor

You must be logged in to vote
1 reply
@dvd101x
Comment options

dvd101x Aug 13, 2024
Collaborator Sponsor

Answer selected by prashasti-k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants