Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a JavaScript function to classify a triangle as equilateral ( all sides equal ) , isosceles ( any two sides equal ) or scalene
Write a JavaScript function to classify a triangle as equilateral all sides equal isosceles any two sides equal or scalene all sides different lengths To make the code clearer, you must use complex conditions. This function has been partially completed for you. Complete the complex conditions so that the appropriate classification is in the variable answer.
function classifyTriangle
Declare variables
var a b c answer;
Read inputs three sides
parseFloat documentgetElementById side value;
b parsefloat documentgetelementById side value;
parsefloat documentgetElementByIdside value;
Process find correct classification and put it in "answer"
Equilateral case first: COMPLETE
if
answer 'Equilateral';
Scalene case next: coMPLETE
else if
answer 'Scalene';
Everything left has to be Isosceles case:
else
answer 'Isosceles';
Display output
document.getElementById output innerHTML
'Classification 'tanswer;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started