Two issues:
=
is for assignment not equality checking – you want to use===
.- You are storing the
value
of the input intoreadInput
, so you don’t need to referencevalue
from it:
function readCommand() {
let readInput = document.querySelector('#commandInput').value
// ↓ no .value, it's already here -----------↑
if (readInput === 'I want an ice cream sandwich') {
// ↑ === vs =
giveIceCreamSandwich()
} else {
alert(`Not a command`);
}
}
CLICK HERE to find out more related problems solutions.