const horn = () => {
console.log("Toot");
};
console.log(horn());
I am getting the output as
Toot undefined
But I can't understand why it is so
const horn = () => {
console.log("Toot");
};
console.log(horn());
I am getting the output as
Toot undefined
But I can't understand why it is so
Your horn function does not return anything ...
const horn = () => {
return 'horn';
};
const horn2 = () => {
console.log('horn');
};
console.log(horn());
horn2();
Because you're function is not returning any values.
const horn = () => {
console.log("Toot");// <-- problem
};
It should be like this
const horn = () => {
return "Toot";
};
console.log(horn());
undefined
can be remove if you return something in horn()
function
const horn = () => {
return "Toot";
};
console.log(horn());