Javascript

Get square Root of any Number in JavaScript

Get square Root of any Number in JavaScript

in this article, we are going to learn how to get the square root of any number in JavaScript. in javascript, we are using Math.sqrt to get square of any number. if the value of a number in negative Math.sqrt returns NAN. So let’s start how to get the square root of any number with the help of JavaScript.

Creating Index Page

in this step, we are going to create a form where you can type any number and get square root with the help of javascript function. and also use internal CSS to design better form and button. You can simply copy the below source code and save it as index.html in your project folder.

Creating javascript function

in this step, we use Math.sqrt function to get the square root of a number. If the value of a number is negative, Math.sqrt returns NaN. copy the below source code and save it as script.js in your project folder and link properly with index.html.

If you facing any type of problem with this source code then you can Download the Complete source code in zip Formate by clicking the below button Download Now otherwise you can send Comment.

About the author

Deepak

Hi, This is Deepak Raj from Sourcecodesite.com.I am a Web Developer, Blogger, Online Instructor and SEO consultant who has been working online for last 4 years and he is running several successful websites on the internet.

Leave a Comment