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
  • 841 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

Enrollment Management System in VB.Net with Full Source Code Inventory Management System in PHP with Source Code Student Grades Management System Using PHP and MySQL with Source Code Attendance Management System using PHP with Source Code College Attendance System (CAS) in VB.NET and MSSQL Free Source Code Online Hotel Reservation System in PHP/MySQLi with Source Code Free school management software Best employee management system in php Student Result Management System using PHP and MySQL QR Code Attendance System Using PHP and MySQL with 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

  • Key Factors Behind Fintech Success in Southeast Asia18 hours 47 minutes ago
  • Space Battle Game Using Pygame in Python with Source Code2 days 17 hours ago
  • How to Find Minimum Spanning Tree Using Prim’s Algorithm in Python2 days 18 hours ago
  • Joke Generator App Using Tkinter in Python with Source Code2 days 18 hours ago
  • Blackjack 21 Game Using Tkinter in Python with Source Code3 days 16 hours ago
  • Base to Base Converter App Using Tkinter in Python with Source Code3 days 17 hours ago
  • Area Unit Converter App Using Tkinter in Python with Source Code3 days 17 hours ago
  • How to Implement DFS Traversal with Recursion in Python4 days 17 hours ago
  • How to Implement Johnson’s Algorithm in Python4 days 18 hours ago
  • Pixel Maker App Using HTML, CSS, and JavaScript with Source Code5 days 17 hours ago

Tag » Area Of Triangle Javascript Code