programming-examples/js/Conditional/Write a JavaScript conditional statement to sort three numbers. Display an alert box to show the result..js

36 lines
716 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
var x= 0;
var y=-1;
var z= 4;
if (x>y && x>z)
{
if (y>z)
{
console.log(x + ", " + y + ", " +z);
}
else
{
console.log(x + ", " + z + ", " +y);
}
}
else if (y>x && y >z)
{
if (x>z)
{
console.log(y + ", " + x + ", " +z);
}
else
{
console.log(y + ", " + z + ", " +x);
}
}
else if (z>x && z>y)
{
if (x>y)
{
console.log(z + ", " + x + ", " +y);
}
else
{
console.log(z + ", " + y + ", " +x);
}
}