Let's say I cast my vote for 1, this if else statement will spit out "Invalid Response". I'm really scratching my head over this one, as I'm sure you have guessed I am at the very beginning of my programming journey. Can anyone explain to me why this isn't working?
answer = prompt
(`What is your favourite programming language?\n0: JavaScript\n1: Python\n2: Rust\n3: C++\n(Write option number)`);
if (answer >= 0 && answer <= 4 && answer == Math.floor(answer)) {
this.answers[answer] += 1;
console.log(poll.answers);
} else {
console.log(`Invalid Response`);
}
},