Estoy tratando de mostrar una alerta que dice qué tipo de triángulo es con las entradas del aviso, pero las condiciones si no funcionan cuando lo coloco dentro de una función. Si no está dentro de una función, funciona bien, pero es un requisito ponerlo dentro.
intenté esto y solo funciona la parte del aviso
<!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>Me he encontrado con un nuevo problema. Necesito usar la función isNan() para verificar si la entrada es un número y agregué esta parte
<!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>y no vuelve a funcionar.