I'm trying to display an alert that says what kind of triangle it is with the inputs from the prompt but the if-else conditions won't work when I put it inside a function. If it isn't inside a function it works fine but it is a requirement to put it inside.
tried this and only the prompt part works
<!DOCTYPE html>
<html>
<body>
<script>
var a = prompt("Enter the length of side A: ");
var b = prompt("Enter the length of side B: ");
var c = prompt("Enter the length of side C: ");
function determineTriangle(a, b, c) {
if (a == b && b == c){
window.alert("The triangle is EQUILATERAL")
}
else if (a == b || b == c || c == a){
window.alert("The triangle is ISOSCELES");
}
else{
window.alert("The triangle is SCALENE");
}
}
</script>
</body>
</html>
I've encountered a new problem. I need to use the isNan() function to check if the input is a number and I added this part
<!DOCTYPE html>
<html>
<body>
<script>
var a = prompt("Enter the length of side A: ");
var b = prompt("Enter the length of side B: ");
var c = prompt("Enter the length of side C: ");
if (isNan(a)) {
window.alert("You did not enter a number")
}
else {
determineTriangle(a, b, c)
}
if (isNan(b)) {
window.alert("You did not enter a number")
}
else {
determineTriangle(a, b, c)
}
if (isNan(c)) {
window.alert("You did not enter a number")
}
else {
determineTriangle(a, b, c)
}
function determineTriangle(a, b, c) {
if (a == b && b == c){
window.alert("The triangle is EQUILATERAL")
}
else if (a == b || b == c || c == a){
window.alert("The triangle is ISOSCELES");
}
else{
window.alert("The triangle is SCALENE");
}
}
determineTriangle(a, b, c);
</script>
</body>
</html>
and It doesn't work again.