SO - weight homework
http://stackoverflow.com/q/8392849/1011582
by dzejkej
HTML
<div id="weight"></div>
<script type="text/javascript">
window.onload = function() {
var wArray = ["fly", "superfly", "bantam", "superbantam", "feather"];
var weight = parseInt(prompt("What is your weight?", 118), 10);
if (weight > 126) {
alert('Please enter a weight lighter than 126');
}
function recruit() {
var weightClass;
if (weight > 0 && weight <= 112) {
weightClass = wArray[0];
} else if (weight > 112 && weight <= 115) {
weightClass = wArray[1];
} else if (weight > 115 && weight <= 118) {
weightClass = wArray[2];
} else if (weight > 118 && weight <= 122) {
weightClass = wArray[3];
} else if (weight > 122 && weight <= 126) {
weightClass = wArray[4];
}
document.getElementById("weight").innerHTML = 'You are in ' + weightClass + ' class!';
}
recruit();
};
</script>