How to Get Area of the Square using JavaScript

In this article, we create a simple program and it’s called how to Get Area of the Square using JavaScript. How to run this program? It will ask the user to give the sides of the square and our program will compute to get the area of the square. You can also check the live demo of this simple article, so you can get an idea and you can try this out, let's start coding. JavaScript This script uses to solve the sides of the square to get the area.
  1. <script>
  2. var side = parseFloat(prompt("Enter the Side of the Square to Get the Area:"));
  3.          
  4. var Solve_TheArea = (side * side);
  5.  
  6. document.write("<br>");
  7. document.write("<h3 style='color:blue; text-align:center;'>How To Get Area Of The Square</h3><br><br>");
  8. document.write("<b style='color:blue; font-size:18px;'> The Sides of the Square is <b style='color:red;'>" + side + ".</b></b><br><br>");
  9. document.write("<b style='color:blue; font-size:18px;'> The Area of the Square is <b style='color:red;'>" + Solve_TheArea + ".</b></b>");
  10. </script>
This is the output: Ask the user to give the sides of a square. Result This is the area of a square: Result This is a simple program and suited for the beginner. Kindly click the "Download Code" below for full source code. If you are interested in programming, we have an example of programs that may help you even just in small ways. Share us your thoughts and comments below. Thank you so much for dropping by and reading this article post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment