Why do you need this function? Consider using some npm module  for version comparsion... for example 
`https://github.com/kevva/compare-version`