if condition
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript Functions</h1>
<p>This example calls a function which performs a calculation, and returns the result:</p>
<input type=input id="p1">
<input type=button onclick="myFunction()" value="C to F">
<input type=button onclick="yourFunction()" value="F to C">
<p id="demo"></p>
<script>
function myFunction() {
var p1= document.getElementById("p1").value;
if(p1>24) { alert("so hot");}
else if(p1==24) { alert("nice");}
else { alert("cool");}
document.getElementById("demo").innerHTML = p1*1.8+32;
}
function yourFunction() {
var p1= document.getElementById("p1").value;
document.getElementById("demo").innerHTML = (p1-32)*5/9;
}
</script>
</body>
</html>