# Find largest of three numbers using Nested if in JavaScript

Example of Nested if: Here, we are going to learn how to find largest of three input numbers using nested if in JavaScript?
Submitted by Pankaj Singh, on June 28, 2019

In this JavaScript example, we are using nested if to find the largest of three numbers, numbers are entering by the user from HTML page.

HTML & JS:

```<!DOCTYPE html>

<HTML>
<SCRIPT>
function Find(){
var a=parseInt(document.getElementById("txta").value);
var b=parseInt(document.getElementById("txtb").value);
var c=parseInt(document.getElementById("txtc").value);

var g=0;

if(a>b){
if(a>c){
g=a;
}
else{
g=c;
}
}
else{
if(b>c){
g=b;
}
else{
g=c;
}
}

document.getElementById("txtd").value=""+g;

}
</SCRIPT>
<BODY>
<hr />
<table>
<tr>
<td>
<label>Enter A</label>
</td>
<td>
<input type="text" name="txta" id="txta" />
</td>
</tr>
<tr>
<td>
<label>Enter B</label>
</td>
<td>
<input type="text" name="txtb" id="txtb"  />
</td>
</tr>
<tr>
<td>
<label>Enter C</label>
</td>
<td>
<input type="text" name="txtc" id="txtc"  />
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
<td>
<input type="button" value="Find" onclick="Find()" />
</td>
</tr>

<tr>
<td>
<label>Greater</label>
</td>
<td>
<input type="text" name="txtd" id="txtd" readonly />
</td>
</tr>
</table>
</BODY>
</HTML>
```

Output