• We just launched and are currently in beta. Join us as we build and grow the community.

How to Get Area of the Square using JavaScript

tm123

DAO Coordinator
T Rep
0
0
0
Rep
0
T Vouches
0
0
0
Vouches
0
Posts
98
Likes
41
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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.

âš™ Live Demo

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. var

    Solve_TheArea =

    (

    side *

    side)

    ;

  4. document.write

    (

    "<br>"

    )

    ;
  5. document.write

    (

    "<h3 style='color:blue; text-align:center;'>How To Get Area Of The Square</h3><br><br>"

    )

    ;
  6. document.write

    (

    "<b style='color:blue; font-size:18px;'> The Sides of the Square is <b style='color:red;'>"

    +

    side +

    ".</b></b><br><br>"

    )

    ;
  7. document.write

    (

    "<b style='color:blue; font-size:18px;'> The Area of the Square is <b style='color:red;'>"

    +

    Solve_TheArea +

    ".</b></b>"

    )

    ;
  8. </

    script>

This is the output:
Ask the user to give the sides of a square.
untitled111.jpg

This is the area of a square:
untitled_17.jpg


âš™ Live Demo

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.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

335,120

335,128

Top