function creatgreeter(name)
{
firstname = name.split(" ")[0];
function greeter()
{
return "Hello " + firstname
}
return greeter;
}
let johncreater = creatgreeter(“John Doe”);
let harrycreater = creatgreeter(“Harry potter”);
console.log(johncreater());
console.log(harrycreater());
Expected output is:
Hello John
Hello harry
output is:
Hello Harry
Hello Harry