How To Get Area Of The Triangle Using JavaScript

Skip to main content sourcecodester logo How To Get Area Of The Triangle Using JavaScript Submitted by alpha_luna on Thursday, May 5, 2016 - 16:56. Related Code: Area of a Rectangle Related Code: Area of a Square In this article, we create a simple program and it’s called How To Get Area Of The Triangle Using JavaScript. How to run this program? It will ask the user to give the base or the width and the height of the triangle and our program will compute to get the area of the triangle. Formula to get the Area of a Triangle Base x Height JavaScript This script used to solve the base and the height of a triangle to get the area.
  1. <script>
  2. var base = parseInt(prompt("Type the width of a Triangle : "));
  3. var height = parseInt(prompt("Type the height of a Triangle : "));
  4. var solving_triangle = (base * height)/2;
  5. document.write("<br>");
  6. document.write("<h2 style='color:blue; text-align:center;'>Area of Triangle</h2>");
  7. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'> Width</b> of Triangle is <b style='color:red;'>" + base + "</b>.</b></b><br /><br />");
  8. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'> Height</b> of Triangle is <b style='color:red;'>" + height + "</b>.</b></b><br /><br />");
  9. document.write("<b style='color:blue; font-size:18px;'> The <b style='color:red;'> Area</b> of Triangle is <b style='color:red;'>" + solving_triangle + "</b>.</b></b>");
  10. </script>

Output:

This is the given Base or Width. Base This is the given Height. Height This is the Result: Result Related Code: Area of a Rectangle Related Code: Area of a Square 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. Tags Area of the Triangle triangles
  • Log in or register to post comments
  • 823 views

Share Source Code or Tutorial

Do you have source code, articles, tutorials or thesis to share? Submit it here by clicking the link below

Submit now...

Popular Source Code

Interactive 3D Christmas Tree Using HTML, CSS and JavaScript with Source Code Online Eyewear Shop Website using PHP and MySQL Free Download Sending SMS using AT Commands via GSM Modem/GSM Phone (receiving SMS-updated) Advanced School Management System with Complete Features Free school management software Online Bus Ticket Reservation Using PHP/MySQLi with Source Code Inventory Management System in PHP with Source Code Library Management Software Online Learning Management System using PHP/MySQLi with Source Code Free and Open Source inventory management system php source code

User account menu

Book navigation

  • SQL Tutorial
  • PHP Tutorial
  • CodeIgniter Tutorial
  • Android Tutorial
  • Visual Basic Tutorial
  • C# Tutorial
  • CSS Tutorial
  • Learn C in 15 Days
  • Object Oriented Programming in C++
  • Data Structures in C++
  • Fundamentals of C Language
  • Learn Object Oriented Programming in C++
  • Java Tutorial
  • Python Tutorial

Recent content

  • Andy's Oracle SQL*Plus games5 hours ago
  • Car Park Management System Using SQLite and Tkinter in Python with Source Code1 day ago
  • How to Find the Total Sum of a Nested List Using Recursion in Python1 day ago
  • Missile Command Game Using Pygame in Python with Source Code2 days ago
  • How to Count Letter Occurrences Recursively in Python2 days 1 hour ago
  • Interactive 3D Christmas Tree Using HTML, CSS and JavaScript with Source Code2 days 9 hours ago
  • Christmas Present Animation Using HTML, CSS and JavaScript with Source Code2 days 16 hours ago
  • Ordering System Using SQLite and Tkinter in Python with Source Code2 days 23 hours ago
  • How to Count the Occurrences of a Word in a Text File in Python3 days ago
  • Universal SQL Generator Using HTML, CSS and JavaScript with Source Code3 days 10 hours ago

Tag » Area Of Triangle Javascript Code