How To Return An Absolute Value

Is there a way to return an absolute value in the code playground?

Or alternatively, is there a way to multiply a number by a negative number?

Hey there, we don’t have the keys added in the app, but JavaScript has a bunch of built in math goodies that you can read about here.

For this case, you’d want to use Math.abs(), which you can read about here.

Hope this helps!

You can make an abs function, just follow me (Ctrl-C):

function abs(num) {
if (num < 0) {
return 0 - num;
return num;

Try these now:


on a new browser window, or in a Grasshopper snippet named ‘Absolutes’.
I hope you get it right! Until next time!

Love, Lawrence

1 Like