Struggling with a mock exam assignment here - trying to create a conversion program from wind speed in meters per second to watts per hour. I've set up a chart with different ranges of m/s to watts, but for some reason, it's not working as expected. It's probably just a silly mistake on my end, so any help would be greatly appreciated :)
<!DOCTYPE html>
<html>
<head>
<meta charset:"utf-8">
<title>Exam Challenge</title>
</head>
<body>
<h2>m/s --> w/h</h2>
<input type="number" id="alfa" placeholder="Enter here" autocomplete="off"><button id="knapp">Calculate</button>
<div id="result">
</div>
<script>
var alfa=document.getElementById("alfa");
var result=document.getElementById("result");
function convert() {
var speed=Math.round(alfa).toFixed(1);
if (speed >= 0 && speed <= 1.5) {
result.innerHTML+="0 watt per hour";
}
else if (speed >= 1.6 && speed <= 3.3) {
result.innerHTML+="2 watt per hour";
}
else if (speed >= 3.4 && speed <= 5.4) {
result.innerHTML+="10 watt per hour";
}
else if (speed >= 5.5 && speed <= 7.9) {
result.innerHTML+="60 watt per hour";
}
else if (speed >= 8 && speed <= 10.7) {
result.innerHTML+="150 watt per hour";
}
else if (speed >= 10.8 && speed <= 13.8) {
result.innerHTML+="400 watt per hour";
}
else if (speed >= 13.9 && speed <= 17.1) {
result.innerHTML+="500 watt per hour";
}
else if (speed >= 17.2) {
result.innerHTML+="0 watt per hour";
}
else {result.innerHTML+="Answer cannot be provided"}
}
knapp.onclick=convert;
</script>
</body>
</html>