Skip to main content

How To Get Area Of The Rectangle Using JavaScript

Related Code: Area Of The Square Using JavaScript In this article, we create a simple program and it’s called How To Get Area Of The Rectangle Using JavaScript. How to run this program? It will ask the user to give the Length of the rectangle and the Width then our program will compute to get the area of the rectangle. Formula to get the Area of a Rectangle Length x Width JavaScript This script used to solve the length and the width of a rectangle to get the area.
  1. <script>
  2. var length = parseInt(prompt("Type the length of a Rectangle : "));
  3. var width = parseInt(prompt("Type the width of a Rectangle : "));
  5. var solving_area = (length * width);
  7. document.write("<br>");
  8. document.write("<h2 style='color:blue; text-align:center;'>How To Get Area Of The Rectangle</h2>");
  9. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'>Length</b> of Rectangle is <b style='color:red;'>" + length + "</b></b>.<br>");
  10. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'>Width</b> of Rectangle is <b style='color:red;'>" + width + "</b></b>.<br><br>");
  11. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'>Area</b> of Rectangle is <b style='color:red;'>" + solving_area + "</b></b>.");
  12. </script>


Ask the user to give the Length and the Width of a Rectangle. This is the given Length. Length This is the given Width. Width This is the result: Result So what can you say about this work? Share your thoughts in the comment section below or email me at [email protected]. Practice Coding. Thank you very much.

Add new comment