- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the cube root of a number in JavaScript?
In this article we are going to discuss how find the cube root of a number with the help of suitable examples in JavaScript.
Using Math object in JavaScript any kind of operation can be done. Math.cbrt(), Math.pow() are the methods especially used to find the cube root of a number and also we can achieve it by using ** operator. It takes a number as a parameter and returns its cube root.
To find the cube root of a number in JavaScript, there are three possible ways. The way to do it is by using cbrt() method, second way is by using pow() method and the third possible way to do it is by using ** operator in JavaScript.
Syntax
The syntax for the cbrt() method is shown below.
Math.cbrt(value)
Here, value is taken as input and it should be a number. It returns cube root of the value.
Example 1
The following is an example program to find the cube root of a number using cbrt() method.
<!DOCTYPE html> <html> <head> <title>To find the cube root of a number in JavaScript</title> </head> <body style="text-align : center"> <h3>To find the cube root of a number in JavaScript</h3> <p id='cbrt'></p> <script> let a = Math.cbrt(36, 1/3); let b = Math.cbrt(125,1/3); let c = Math.cbrt(-36.1/3); let d = Math.cbrt(-125,1/3); document.getElementById('cbrt').innerHTML = `The cube root value for 36 is ${a} ${'<br/>'} The cube root value for 125 is ${b} ${'<br/>'} The cube root value for -36 is ${c} ${'<br/>'} The cube root value for -125 is ${d} ${'<br/>'}`; </script> </body> </html>
On executing the above code, the following output is generated.
Example 2
The following is an example program to find the cube root of a number using pow() method.
<!DOCTYPE html> <html> <head> <title>To find the cube root of a number in JavaScript</title> </head> <body style="text-align : center"> <h3>To find the cube root of a number in JavaScript</h3> <p id='cbrt'></p> <script> let a = Math.pow(27,1/3); let b = Math.pow(125,1/3); let c = Math.pow(64,1/3); let d = Math.pow(39,1/3); document.getElementById('cbrt').innerHTML = `The cube root value for 27 is ${a} ${'<br/>'} The cube root value for 125 is ${b} ${'<br/>'} The cube root value for 64 is ${c} ${'<br/>'} The cube root value for 39 is ${d} ${'<br/>'}`; </script> </body> </html>
On executing the above code, the following output is generated.
Example 3
The following is an example program to find the cube root of a number using ** operator.
<!DOCTYPE html> <html> <head> <title>To find the cube root of a number in JavaScript</title> </head> <body style="text-align : center"> <h3>To find the cube root of a number in JavaScript</h3> <p id='cbrt'></p> <script> let a = 27 ** (1/3); let b = 125 ** (1/3); let c = 36 ** (1/3); let d = 75 ** (1/3); document.getElementById('cbrt').innerHTML = `The cube root value for 27 is ${a} ${'<br/>'} The cube root value for 125 is ${b} ${'<br/>'} The cube root value for 36 is ${c} ${'<br/>'} The cube root value for 75 is ${d} ${'<br/>'}`; </script> </body> </html>
On executing the above code, the following output is generated.
- Related Articles
- Java program to find the cube root of a given number
- How to find the cube root of 11?
- Find the cube root of following number n-2744
- How to find the cube root of negative values in R?
- Find the cube root of 1404928.
- Find the cube root of 512.
- Find the Cube Root Of $-5$
- Find the cube root of 216.
- Find the cube root of $1.728$.
- Find the cube root of $-0.001331$.
- Find the cube root of $0.000001$.
- Making use of cube root table find the cube root of following :a) 11005 b) 1346
- Find Cube Root Of 9261
- Find the cube root of the following rational number.$frac{4913}{3375}$.
- Find the smallest number by which the given number must be divided to obtain a perfect cube also find the cube root of the quotient: $576$.
