I am trying to make a webpage that when you put a number in the box, and press a button, it tells you if the number is even or odd in the console, but when I press submit, it doesn’t do anything.
This is my code, is there anything I should change or fix?
I thought it would tell me if it was even or odd but it didn’t do that.
const num = document.getElementById("numberText");
const result = document.getElementById("result");
const button = document.getElementById("submitBtn");
function isEven(number){
if (number % 2 === 0) {
return "this number is even";
} else {
return "this number is odd";
}
}
if (button.clicked == true) {
console.log(isEven(num));
}