<p id="demo"></p>
<p id="demo2"></p>
<script>
function myFunction(x, y) {
var mess2;
var x = document.getElementById("id1").value;
var y = document.getElementById("id2").value;
var z = Math.abs(+ x) + Math.abs(+ y);
if (var z <= 2.50) {
mess2 = "message 1";
} else if (2.50 < var z <= 4.00) {
mess2 = "message 2";
} else if (4.00 < var z <= 5.00) {
mess2 = "message 3";
} else {
mess2 = "message 4";
}
document.getElementById("demo").innerHTML = + mess2;
}
</script>
so this is my little function that I need to use to show some message depending on the inputed value that the user will write in an input window. the code worked fine when I outputed only the variable z as number, but when I added this if function it outputs nothing
Any advice? thank you :)
var z
inside an expression is a syntax error. And there's no chained comparison in JavaScript.