Largest of three numbers

 AIM: Find the largest of three numbers.

Source Code:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Document</title>

</head>

<body>

<input type="button" onclick="gt3()" value="click here">

<script>

function gt3() {

var n1= parseInt(prompt("first number: "));

var n2= parseInt(prompt("second number: "));

var n3= parseInt(prompt("third number: "));

if(n1>n2){

if(n1>n3){

document.writeln(n1+" is the greatest number");}

else{

document.writeln(n3+" is the greatest number");}}

else if(n2>n3){

document.writeln(n2+" is the greatest number");}

else{

document.writeln(n3+" is the greatest number");}}

</script>

</body>

</html>

Comments

Popular posts from this blog

Calculate Factorial using While loop in JavaScript.

Calculator

Simple calculator