+ 3
Manipulating Function
Why is the output undefined even tho there is return statement. function david(small_head) { console.log(small_head); } function yusuff(brilliant, handsome) { let grillo = brilliant + handsome; return david(grillo); } console.log(yusuff(5,5));
7 Antworten
+ 1
Ibrahim Yusuf what you should do is: function david(xyz){ return xyz;
/*in this case, you are telling the function to return the result/value of xyz whenever the function is called*/
/* using console.log() instead of a return here would make the function undefined, cos it means no values is assigned to it*/};
function yusuf(b,h){
let g = b + h;
/* here, you are calling the function david inside of yusuf assigning the values/result from "g" to it as an argument, so a value would be returned*/
return david(g);
}
console.log(yusuf(5,5));
// i hope this helps.
+ 3
Because the function david() didn't return any values. So that giveundefined.
+ 2
Ibrahim Yusuf What do you want return from david()?
+ 2
Vadivelan Just want to get the output of both david() and yusuff();
+ 2
Infinite Thank you, That reall helps
+ 1
There is no return in david().