4
I need to create a function that takes three numbers as parameters and returns the largest of them. If two or three are equal, it shows the same value.
I was able to make the comparison, but it remains to show that if it has a repeated value it shows this value.
var n1 = parseFloat(prompt("Digite um número:"));
var n2 = parseFloat(prompt("Digite um número:"));
var n3 = parseFloat(prompt("Digite um número:"));
function maiorDosTres() {
var a = Array.prototype.sort.call(arguments);
alert( "O maior número é: " + a[a.length - 1] + " e o menor é: " + a[0]);
}
maiorDosTres(n1, n2, n3);Q
"If two or three are equal, it shows the same value" - This premise does not affect at all the original objective. If you show the largest, it will be valid for all different elements, as for any quantity of larger elements equal.
– Isac
Or the goal is to know if the largest element is repeated or single ?
– Isac