I am trying to make a callback function that has an anonymous function nested inside. My code looks something like this:
function submitGuess(guess) {
if (guess.length === 5) {
console.log("The guess was 5 letters");
const postGuess = async () => {
console.log("Anon function initiated")
const res = await fetch(SOME_URL);
}
}
}
submitGuess(guess)
But the anonymous function never initiates. The second console.log never runs, and I can't figure out why.
postGuess(). Note that, even after doing that, the value ofres, the result of the fetch() will be discarded.submitGuess()? Where and how are you callingpostGuess()?