JavaScript and HTML code to find largest of three numbers - Practical [ SWPD 4311603 ]

Practical Aim:
Use JavaScript to find the highest from the given three values.

First, try at own

Video Tutorial: JavaScript to Find the Largest Number Among Three Numbers


findgreatestnumber.html file

<html lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Find Greates Number from Three Number</title>
margin: 20px;
padding: 20px;
background-color: antiquewhite;

background-color: black;
color: white;
padding: 3px;

border-radius: 5px;
height: 50px;
font-size: 20px;
font-size: 20px;

font-size: 20px;
padding: 10px;
width: 400px;
font-weight: bold;

function largest(){
var num1, num2, num3;
num1 = Number(document.getElementById("n1").value);
num2 = Number(document.getElementById("n2").value);
num3 = Number(document.getElementById("n3").value);


if(num1 > num2 && num1 > num3)
window.alert(num1 + " Number1 is Greatest number");
else if(num2 > num1 && num2 > num3){
window.alert(num2 + " Number2 is Greatest number");
else if(num3 > num1 && num3 > num2){
window.alert(num3+ " Number3 is Greatest number");


<div class="wrapper">
<h1> Find the greatest value from entered Three value</h1>
<label>Enter Number 1 </label><input type="number" id="n1"></input><br><br>
<label>Enter Number 2 </label><input type="number" id="n2"></input><br><br>
<label>Enter Number 3 </label><input type="number" id="n3"></input><br><br>

<button onClick="largest()" >Find The Greatest Number</button>



Try here

<!DOCTYPE html >
<html >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<h1> Try your code here</h1>


Post a Comment