Back to feed
Renewal·서른의 생활코딩

Sample Source 1) JavaScript Basics (else-if Statement)

NS
normalstory
cover image

else if statement



 

Example 7)


Basic form
 


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">


<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />

<title> else if statement </title>

<meta name="Keywords" content="" />

<meta name="Description" content="" />

</head>

<body>


<script type="text/javascript">

//<!CDATA[

// Your blood type? a,b,ab,o -> you are such-and-such :: if 1st else if 2nd else you run it once and it works.

var blood=prompt("Your blood type?(in lowercase)","a");


if(blood=="a"){

document.write("timid personality");

}else if(blood=="b"){

document.write("highly volatile");

}else if(blood=="ab"){

document.write("not so good personality");

}else if(blood=="o"){

document.write("hot-tempered");

}else{

alert("in lowercaseenter the blood type please !!!");

}

//]]]]>

</script>


</body>

</html>




 

Applied form



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"


"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">




<head>


<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />


<title> else if statement </title>


<meta name="Keywords" content="" />


<meta name="Description" content="" />


</head>


<body>




<script type="text/javascript">


//<!CDATA[


// when the 2-subject average is 90+, print 'a'; 80=b, 70=c, 60=d, 50 or below=f


/*


var sung1=parseInt(prompt("Enter Korean midterm score",""));


var sung2=parseInt(prompt("Enter English midterm score",""));


var sum=sung1+sung2;


var avg=sum/2




if(avg>=90){


document.write("A");


}else if(avg>=80){


document.write("B");


}else if(avg>=70){


document.write("C");


}else if(avg>=60){


document.write("D");


}else{


document.write("E");


}*/


var sung1=prompt("Enter Korean midterm score","");


var sung2=prompt("Enter English midterm score","");


var sum="sung1"+"sung2";


var avg=sum/2




if(avg>=90){


document.write("A");


}else if(avg>=80){


document.write("B");


}else if(avg>=70){


document.write("C");


}else if(avg>=60){


document.write("D");


}else{


document.write("E");


}


//]]]]>


</script>




</body>


</html>

This English version was translated by Claude.

친절한 찰쓰씨
Written by
친절한 찰쓰씨

Pleasant Charles — UI/UX researcher at AIT. Keeping notes on design, planning, and slow days here since 2010.

More on the author's page

Keep reading

Renewal

Why You Should Use .html Instead of .md Seeing Is Believing

Jul 25, 2026·1 min
Renewal

The Most Important Thing About AX

Jul 17, 2026·2 min
Renewal

디지털 기술과 혁신에 대한 논고(지탱하는 힘)

Jul 17, 2026·5 min