I am challenging myself by writing a simple JavaScript callback hell to grasp the concept without using the widely spread setTimeout function examples on the net. I did something wrong and haven't succeeded yet to nest my callbacks and return the final result.
const multiplication = (a, b) => {
let multiply = a * b;
console.log(`${multiply} from multiplication`);
return multiply;
};
const addition = (multiply, n1) => {
let add = multiply + n1;
console.log(`${add} from addition`);
return division(add);
};
const division = (add) => {
let div = add / 2;
console.log(`${div} from division`);
return div;
};
console.log(
multiplication(10, 20, () => {
addition(multiply, 100, () => {
division(add);
});
})
);