Finding square root of a number

Hi :wave:

I wanted to know if there is any way to find a square root of a number. I didn’t find any keyword regarding it.

Thanks in advance.

// Rohit Elamurugan

1 Like

Ummm I dont know but i learned it in 5th grade

1 Like

I found a way to create a square root! Because math.sqrt doesn’t work in grasshopper, I created a different function.

function sqrt(x) {
    return x**0.5;
}
console.log(sqrt(numberGoesHere));

See if this works for you.
-Friidays :blush:

1 Like

And by the way, the numberGoesHere part can be filled with whatever number you’d like. :hugs:

1 Like

Oops, My bad! Math.sqrt does work in grasshopper, it just needs to be capitalized. If you want to print out a square root, the simpler way is to do it this way:

console.log(Math.sqrt(numberGoesHere));

Of course, you could also use the function, but this is quicker and easier.
-Friidays :grin:

1 Like