You are here: Home / Topics / Write a code to find Maximum Edge of a Triangle in JavaScript

Write a code to find Maximum Edge of a Triangle in JavaScript

Filed under: JavaScript on 2023-08-06 21:00:59

Create a function that finds the maximum range of a triangle's third edge, where the side lengths are all integers.
 

Examples:

nextEdge(8, 10) ➞ 17

nextEdge(5, 7) ➞ 11

nextEdge(9, 2) ➞ 10

 

Notes:

We will use this algorithm to find the maximum range of a triangle's third edge

(side1 + side2) - 1 = maximum range of third edge.

<script>

function nextEdge(side1, side2){

return (side1 + side2) - 1; 

}

 

var side1 = 8;

var side2 = 10;

console.log(nextEdge(side1, side2)); //this will print 17

</script>


About Author:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free. Share your stuff here so that others can get benefitted.