Single responsibility with javascript