Finding Nth Root Of A Number Using JavaScript

With below code, we can find the nth root of a number by making use of Math.pow() function in javascript,
  1.  Number :  
  2. <input type="text" id="txtnumber" /><br />  
  3. <br />  
  4. Root :  
  5. <input type="text" id="txtroot" /><br />  
  6. <br />  
  7. <button onclick="getrootval()">  
  8.         Find Root</button>  
  9. <script>  
  10.         function getrootval() {  
  11.             var num = document.getElementById("txtnumber").value;  
  12.             var root = document.getElementById("txtroot").value;  
  13.             var str = root + "th root of " + num + " is ";  
  14.             if (parseFloat(root) == 1.0) {  
  15.                 str = "First Root of " + num + " is ";  
  16.             }  
  17.             else if (parseFloat(root) == 2.0) {  
  18.                 str = "Square Root of " + num + " is ";  
  19.             }  
  20.             else if (parseFloat(root) == 3.0) {  
  21.                 str = "Cube Root of " + num + " is ";  
  22.             }  
  23.             num = Math.pow(num, (1 / parseFloat(root)));  
  24.             alert(str + num);  
  25.         }      
  26. </script>  
.