I have written a small code-snippet it prints the output but its not returning any value from the callback()
Can you please help me where am I making a mistake `
function helloworld(string,callback){
//callback(string){
if ( string == "Tim"){
callback('null',string+" "+"Little");
} else if ( string == "Jason"){
callback('null',string+"Right") ;
} else {
callback ('error : No rule is defined for '+string,string);
}
// };
}
function invoke_callback(input){
helloworld(input,
function(err,name){
if (err != 'null'){
console.log(err);
return(err);
}
console.log(name);
return(name);
}
)
}
console.log(invoke_callback("Tim"));
`
Its output is - Tim Little undefined
I am expecting - Tim Little Tim Little