Discussion is about the working of code

I formatted your code for you, see here for details:

In this case, your function appears fine - but it isn’t showing anything because you don’t specify how the returned value should be shown. You could either write it to your HTML page, or log it to the console, but those are both things you have to code specifically - return alone doesn’t do that automatically.