Not All Code Paths Return A Value Javascript