---
title: "Javascript program to find to squire root of a number"  
description: "Javascript program to find to squire root of a number"  
author: "Amartya Singh"  
published: 2023-02-16  
updated: 2023-11-26  
canonical: https://www.mindstick.com/forum/157406/javascript-program-to-find-to-squire-root-of-a-number  
category: "javascript"  
tags: ["jquery", "javascript", "programs"]  
reading_time: 1 minute  

---

# Javascript program to find to squire root of a number

Find the squire [root](https://answers.mindstick.com/qa/49855/tell-me-what-is-root-port-in-spanning-tree-protocol) of a number [input](https://www.mindstick.com/forum/159209/how-can-i-read-convert-an-input-stream-into-a-string-in-java) by the [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) using javascript.

## Replies

### Reply by Aryan Kumar

You can find the square root of a number in JavaScript using the **Math.sqrt()** function. Here's a simple example:

```plaintext
// Function to find the square root of a number
function findSquareRoot(number) {
  // Check if the number is non-negative
  if (number >= 0) {
    // Use Math.sqrt() to calculate the square root
    return Math.sqrt(number);
  } else {
    // If the number is negative, return NaN (Not a Number)
    return NaN;
  }
}

// Example usage
let numToFindSquareRoot = 25;
let result = findSquareRoot(numToFindSquareRoot);

if (!isNaN(result)) {
  console.log(`The square root of ${numToFindSquareRoot} is: ${result}`);
} else {
  console.log(`Cannot calculate the square root of a negative number.`);
}
```

In this example, the **findSquareRoot** function takes a number as an argument, checks if it's non-negative, and then uses **Math.sqrt()** to calculate the square root. If the number is negative, it returns **NaN** (Not a Number).

You can change the value of **numToFindSquareRoot** to find the square root of different numbers. Note that the result will be a floating-point number, even if the input is an integer.


---

Original Source: https://www.mindstick.com/forum/157406/javascript-program-to-find-to-squire-root-of-a-number

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
