JavaScript program to calculate triangle circumference

Views: 159   

Following program shows you how to calculate triangle circumference.
This program gets triangle sides from user and calculates circumference and prints it using following formula
Circumference = side1 + side2 + side3

var triangleSide1 = parseInt(prompt("Enter the side1 of triangle:"));
var triangleSide2 = parseInt(prompt("Enter the side2 of triangle:"));
var triangleSide3 = parseInt(prompt("Enter the side3 of triangle:"));
var circumferenceOfTriangle = triangleSide1 + triangleSide2 + triangleSide3;
console.log("Circumference of triangle is: " + circumferenceOfTriangle);


Enter the side1 of triangle:
Enter the side2 of triangle:
Enter the side3 of triangle:
Circumference of triangle is: 60.0
On By