Arrow function is skipped
Arrow function is skipped
I don't see anything wrong with this arrow function but even if I replace position with the number 2, it still doesn't run its internals
const isValidMove = (position) => {
console.log("a")
const valid = !isNaN(+position);
return valid;
}
I don't get anything logged to the console even with this:
const isValidMove = (2) => {
console.log("a")
const valid = !isNaN(+position);
return valid;
}
Also, which console are you looking at? When I "run" version 2, I get
SyntaxError: missing formal parameter
– Chris G
Jun 29 at 22:00
SyntaxError: missing formal parameter
1 Answer
1
You've made a fine arrow function, but you're not calling it properly. isValidMove
will be a function based on your first snippet. To use it, you just need to call it and pass the position
argument with isValidMove(2)
. Try this instead:
isValidMove
position
isValidMove(2)
const isValidMove = (position) => {
console.log("a")
const valid = !isNaN(+position);
return valid;
}
console.log(isValidMove(2))
omg didn't even see that thx
– PositiveGuy
Jun 29 at 21:57
@PositiveGuy Are you saying you never called the function...?
– Chris G
Jun 29 at 21:58
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
How are you calling the function? And version 2 is a syntax error.
– Chris G
Jun 29 at 21:54