LearnFrenzy
Sign in Take a free test

Callbacks · Find the Error · Question 5

Error: calling a function without its callback Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 5 Back to Exercise

The code below stops with an uncaught error. Which statement correctly describes the problem?

main.js
function fetchScore(student, callback) {
  const score = student.length * 10;
  callback(score);
}
fetchScore("Asha");
  • A TypeError: callback is not a function – fetchScore was called without one Correct
  • B It returns 40
  • C It prints 40
  • D Nothing happens
Correct Answer: Option A

The missing argument is undefined and calling undefined throws. Pass a callback, or guard it: callback?.(score).

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links