Search⌘ K
AI Features

Solution Review: Callback Functions

Explore how to identify and fix common issues with callback functions in JavaScript. This lesson helps you understand the correct way to pass callbacks without prematurely invoking them, solidifying your grasp of asynchronous programming basics through practical debugging.

We'll cover the following...

Solution

Javascript (babel-node)
function feelings(val, func) {
console.log("I am " + val + ", " + func(2));
}
var laughing = function(num) {
var laugh = "";
for (var i = 0; i < num; i++) {
laugh = laugh + "ha";
}
return laugh;
};
function display() {
feelings("happy", laughing);
}
display()

Explanation

This is a ...