how to get value from one function to another in javascript