Simulate CommonJS: export add function and use it.
Ready — edit the code above and click Run.
function add(a, b) { return a + b; }
module.exports = { add };
const { add: addFn } = module.exports;
console.log(addFn(2, 3));
Try solving on your own first, then reveal the official answer.
CommonJS vs ESM is a frequent Node interview question—know both syntaxes.