https://tutorial.eyehunts.com/js/javascript-function-returns-undefined-instead-of-value/
JavaScript function returns undefined instead of value