I admit I have not looked much, but this is eye catching: as the return statement returns something and stops the function, everything that is after a return statement inside a function is not executed
Can I also advice you tidy up your code? You can just paste your JavaScript in something like jsfiddle.net and press tidy and it will be easier to read
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.
See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.