<meta charset="UTF-8" />
<h1>What your IMC</h1>
<h2 id="demo"></h2>
<script>
document.write("Hello");
function toBreakLine() {
document.write("<br><br>");
}
function toShowMessage(message) {
//document.write(message)
document.querySelector("#demo").innerHTML = message;
toBreakLine();
}
//user input: number of wins or draws
function toEnterValue(word) {
let valor = parseInt(prompt(`Enter ${word}: `));
return valor;
}
//Calculate the total points
function toCalcPoints(wins, draws) {
return wins * 3 + draws;
}
function main() {
const pointsLastYear = 28;
const wins = toEnterValue("wins");
const draws = toEnterValue("draws");
const pointsCurrYear = toCalcPoints(wins, draws);
let teamPerfor = "Your team is "; //team's performance
if (pointsLastYear > pointsCurrYear) {
teamPerfor += "worse than last yer";
} else if (pointsLastYear < pointsCurrYear) {
teamPerf += "better than last year";
} else teamPerfor += "equal to last year";
return teamPerfor
}
toShowMessage(main())
</script>