write a programme using if else;
<html>
<head><title>javascript</title>
<script>
function ifelse(){
let math,punjabi,science,percentage,total,average;
math=23;
punjabi=36;
science=20;
total=math+punjabi+science;
percentage=total/150*100;
average=total/3;
if(percentage>=90 && average>=45){
document.write("pass well done! keep it up");
}
else if(percentage>=90 || average>=40){
document.write("pass good");
}
else if(percentage>=40 && average>=20){
document.write("pass");
}
else {
document.write("fail");
}
}
document.getElementById("demo").innerHTML=ifelse();
</script>
</head>
<body>
<p id="demo"></p>
</body>
</html>
output:-
pass
16. Write a programme using for loop;
<html>
<head><title>javascript</title>
<script>
function loop(){
for(let a=0; a<=5; a++){
document.write("hello"+"<br>")
}
}
document.getElementById("demo").innerHTML=loop();
</script>
</head>
<body>
<p id="demo"></p>
</body>
</html>
hello
hello
hello
hello
hello