Question: Triangle perimeter and area ( JavaScript ) A triangle's three vertices can be defined with three ( x , y ) coordinates. Ex: The figure
Triangle perimeter and area JavaScript
A triangle's three vertices can be defined with three x y coordinates. Ex: The figure below shows a triangle with vertices and
Write two functions: trianglePerimeter and triangleArea Both functions have six integer parameters representing the coordinates of a triangle's three vertices.
The trianglePerimeter function should calculate the length of each side using the distance formula below. Then the function should return the sum of the three sides' length.
Ex: The function call trianglePerimeter returns the sum of the three sides' length:
Distance from to
Distance from to
Distance from to
The triangleArea function should calculate and return the triangle's area using the following equation:
xY xY Y
Ex: The function call triangleArea returns
Hint: The JavaScript Math object has methods for squaring numbers, calculating a number's square root, and finding a number's absolute value.
Need to know what code to write the TODO area below
function trianglePerimeterx y x y x y
TODO: Write your code here
function triangleAreax y x y x y
TODO: Write your code here
console.logTesting trianglePerimeter;
let perimeter trianglePerimeter;
console.logPerimeter perimeter;
console.logTesting triangleArea;
let area triangleArea;
console.logArea area;
Do NOT remove the following line:
export trianglePerimeter, triangleArea ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
