Higher order function javascript

while calling creategreeter like this
function createGreeter(name){
let firstName=name.split(" ")[0]
function greeter(){
console.log("Hello "+firstName)
}
return greeter
}

createGreeter(“abhinav pandey”)
why this is not printing first name since it is returning a function and which contains console.log why it is requiring an extra variable for printing purpose??

yes, it is returning a function(greeter) but that function is not called anywhere, it is just defined in creategreeter

thus in order to call it we will be needing a variable

let a = creategreeter(“abhinav pandey”)
a()

or we can also do it without variable

creategreeter(“abhinav pandey”)()