Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

JavaScript SQRT

by suresh

The JavaScript SQRT function is a Math function used to find the square root of a specified expression or a specific number. The syntax of the JavaScript SQRT Function is:

Math.sqrt(number);
  • If the number argument is a positive integer, the SQRT function will return the square root of a given value.
  • If it is Negative or not a number, JavaScript Square root function will return NaN.
  • And if it is Null, the SQRT function returns Zero.

JavaScript SQRT Function Example

The JavaScript SQRT function finds the square root of a given number. In this example, we are going to find the JavaScript square root of different data types and display the output

<!DOCTYPE html>
<html>
<head>
    <title> JavaScript SQRT Function </title>
</head>
<body>
  <h1> JavaScript SQRT Function </h1>
  <p id = "Pos"></p>
  <p id = "Neg"></p>
  <p id = "Dec"></p>
  <p id = "Neg_Dec"></p>
  <p id = "Str"></p>
  <p id = "Null"></p>
  <script>
    document.getElementById("Pos").innerHTML = Math.sqrt(10);
    document.getElementById("Neg").innerHTML = Math.sqrt(-10);
    document.getElementById("Dec").innerHTML = Math.sqrt(14.05);
    document.getElementById("Neg_Dec").innerHTML = Math.sqrt(-6.05);
    document.getElementById("Str").innerHTML = Math.sqrt("JavaScript");
    document.getElementById("Null").innerHTML = Math.sqrt(null);
  </script>
</body>
</html>

ANALYSIS

  1. First two statements, We used the SQRT Function directly on the Positive and negative integer. From the below screenshot, you can see the SQRT Function is returning NaN as output for negative integer
  2. Following four statements, we used the JavaScript SQRT Function on the Positive and negative Decimal values. As we said before, the SQRT Function is returning NaN for negative decimal.
  3. SQRT Function on the string value and this also returns NaN
  4. Last, We tried Js SQRT Math function on Null value, and it returns Zero as output

OUTPUT

JavaScript SQRT Function

Placed Under: JavaScript

  • SQL DML, DDL, DCL & TCL Cmds
  • SQL NOT EXISTS Operator
  • SQL UPDATE from SELECT
  • SQL AFTER UPDATE Triggers
  • SQL Get Column Names in Table
  • SQL IF ELSE
  • SQL ACID Properties
  • SQL FOR XML PATH
  • Java Two Dimensional Array
  • Java Perfect Number Program
  • Java Count Digits in a Number
  • C Compare Two Strings Program
  • C Print Prime Numbers 1 to 100
  • C program to Reverse a String
  • C Palindrome Number Program
  • C Program for Palindrome String
  • C Remove Duplicate String Chars
  • C Square of a Number Program
  • C Sum and Average of N Number
  • Python Fibonacci Series program
  • Python Area Of Circle Program
  • Python Prime Numbers 1 to 100
  • Python Program for Leap Year
  • Tableau Rank Calculation
  • Tableau Google Maps usage
  • Power BI Format Dates
  • Power BI Top 10 Filters
  • Power BI – Create Hierarchy
  • Power BI DAX Math Functions
  • Learn SSIS in 28 Days
  • SSIS Transformations
  • SSIS Incremental Load
  • SSRS Drill Through Reports
  • SSRS Drill Down Reports
  • R Programming Tutorial
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy