Valid JS-Dev-101 Dumps shared by EduDump.com for Helping Passing JS-Dev-101 Exam! EduDump.com now offer the newest JS-Dev-101 exam dumps, the EduDump.com JS-Dev-101 exam questions have been updated and answers have been corrected get the newest EduDump.com JS-Dev-101 dumps with Test Engine here:
Code: 01 const sayHello = (name) => { 02 console.log('Hello ', name); 03 }; 04 05 const world = () => { 06 return 'World'; 07 }; 08 09 sayHello(world); This does not print "Hello World". What change is needed?
Correct Answer: A
Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge: Currently: sayHello expects a value name and prints it. world is a function that returns 'World'. sayHello(world); passes the function object itself, not the result of calling it. So name inside sayHello is a function, not the string "World". To keep the call sayHello(world) yet get "World", sayHello must call the function parameter: const sayHello = (name) => { console.log('Hello', name()); }; Now: sayHello(world) passes the function. Inside sayHello, name() calls world(), which returns "World". The console logs "Hello World". Why the others are wrong: B: Changing line 7 to }(); would attempt to IIFE the function definition and break the declaration. C: sayHello(world)() would try to call the return value of sayHello, which is undefined, causing an error. D: Changing world to a function declaration does not change the fact that it is passed as a function reference; sayHello still prints the function object, not 'World'. ________________________________________