You’d need to save the value to a common location. For example, “window” should be available to both snippets. You could set it in one snippet, and pick up from the other. However, you don’t know for sure what order the snippets will run, and the value will persist between pages if not cleared.
Could the functionality be moved to a nanoflow? You may find it easier to work with as you could use Mendix entities for data transfer and storage.
Good luck