Reputation: 77
So, I have a task assigned to me but I find that the instructions is a little deep and english isn't my native language. So here's the instructions:
move
move
has a value, your expression should evaluate to that value.getInput()
.And here's how I've seen it:
var move = getInput();
if (move === getInput) {
console.log("Player: " + move);
}
else if (move === null) {
getInput():
};
return getInput (move);
Upvotes: 2
Views: 96
Reputation: 4007
Truthy
and Falsy
valuesgetInput
is a function. When you get to
if (move === getInput) // rest of code
This is checking to see if the result of calling getInput() is the reference to the function itself ... this is probably not what you want.
Truthy
values.null
is not truthy so a sufficient test for your input would be
if (move) // rest of code.
move will be populated with getting the input. so thats why it will make sense to console.log it in the body of the if statement.
you don't need to explicity check using else if
because you are checking a direct negation of your if.
so instead your format should be
if (move) {
// ...
} else { // no need for else if here. null is implied.
// ...
}
Upvotes: 3