Answered step by step
Verified Expert Solution
Link Copied!

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 a,b,c
a= parseFloat (document.getElementById ('side1'). value);
b = parsefloat (document.getelementById ('side2'). value);
c= parsefloat (document.getElementById('side3'). 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;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

How competitive is the external environment of your organization?

Answered: 1 week ago

Question

What other organizations compete on this issue?

Answered: 1 week ago

Question

What significant opposition exists?

Answered: 1 week ago