To implement:

Write function to find the least greatest value of three numbers that is not zero.

 

<head>
<title></title>
<script language="JavaScript">
<!-- Start Script

// minDif finds the min value > 0 
// function assumes values in order (ie. difRed, difGreen, difBlue)
// Analysis

function minDif(a, b, c)
{

var min = "";
if(Math.abs(a)>=Math.abs(b))
	if(Math.abs(a)>=Math.abs(c))
	// a >= b && a >= c
	// Analysis
		if(Math.abs(b==0) && Math.abs(c==0))
			min = "red";
		else if(Math.abs(b==0) || (Math.abs(b)>Math.abs(c) && Math.abs(c)!=0))
			min = "blue";
		else 
			min = "green";
	
	else
	// c > a && a >= b
	// Analysis
		if(Math.abs(a)==0 && Math.abs(b) ==0)
			min= "blue";
		else if(Math.abs(b)==0)
			min= "red";
		else 
			min = "green";

else 
	if(Math.abs(b)>=Math.abs(c))
	// a < b && b >= c
	// Analysis
		if(Math.abs(a==0) && Math.abs(c==0))
			min = "green";
		else if(Math.abs(a==0) || (Math.abs(a)>Math.abs(c) && Math.abs(c)!=0))
			min= "blue";
		else
			min = "red";

	else
	// a < b && b < c
	// Analysis
		if(Math.abs(a)==0)
			min = "green";
		else
			min = "red";

return min;
}

// tests for min function
// Analysis

document.writeln("minDif(0, 0, 0): " + minDif(0, 0, 0) + "<br>");
document.writeln("minDif(20, 0, 0): " + minDif(20, 0, 0) + "<br>");
document.writeln("minDif(0, 20, 0): " + minDif(0, 20, 0) + "<br>");
document.writeln("minDif(0, 0, 20): " + minDif(0, 0, 20) + "<br>");
document.writeln("minDif(20, 20, 0): " + minDif(20, 20, 0) + "<br>");
document.writeln("minDif(0, 20, 20): " + minDif(0, 20, 20) + "<br>");
document.writeln("minDif(20, 0, 20): " + minDif(20, 0, 20) + "<br>");
document.writeln("minDif(10, 0, 20): " + minDif(10, 0, 20) + "<br>");
document.writeln("minDif(20, 0, 10): " + minDif(20, 0, 10) + "<br>");
document.writeln("minDif(0, 10, 20): " + minDif(0, 10, 20) + "<br>");
document.writeln("minDif(0, 20, 10): " + minDif(0, 20, 10) + "<br>");
document.writeln("minDif(10, 20, 0): " + minDif(10, 20, 0) + "<br>");
document.writeln("minDif(20, 10, 0): " + minDif(20, 10, 0) + "<br>");
document.writeln("minDif(20, 10, 10): " + minDif(20, 10, 10) + "<br>");
document.writeln("minDif(10, 20, 10): " + minDif(10, 20, 10) + "<br>");
document.writeln("minDif(10, 10, 20): " + minDif(10, 10, 20) + "<br>");
document.writeln("minDif(10, 20, 30): " + minDif(10, 20, 30) + "<br>");
document.writeln("minDif(10, 30, 20): " + minDif(10, 30, 20) + "<br>");
document.writeln("minDif(20, 10, 30): " + minDif(20, 10, 30) + "<br>");
document.writeln("minDif(30, 10, 20): " + minDif(30, 10, 20) + "<br>");
document.writeln("minDif(20, 10, 30): " + minDif(20, 10, 30) + "<br>");
document.writeln("minDif(20, 30, 10): " + minDif(20, 30, 10) + "<br>");
document.writeln("minDif(30, 20, 10): " + minDif(30, 20, 10) + "<br>");
document.writeln("minDif(20, 20, 20): " + minDif(20, 20, 20) + "<br>");

// End Script -->
</script>
</head>
<body>

</body>
</html>

 

Execute code or main page