Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, January 15, 2013

Heron's Triangle Area Formula Javascript Implementation



Question: Given a triangle with sides 13, 14 and 15, what is it's area?

Answer: 84

Solved using the script below:

console.log("********************************");
function Herons(a,b,c){
var perimeter=a+b+c;
var s = perimeter/2;
return Math.sqrt(s*(s-a)*(s-b)*(s-c));
}
console.log(Herons(13,14,15));

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts