How can I simplify this JavaScript and not duplicate the code for different variables

welcome to shbcf.ru