Hi. Welcome to the forum.
FYI, this JavaScript (very different from Java & such searching for help on Java will not get answers for JavaScript)
This is (one of the ways) you can approach the problem. What have you done and why does it not work? post a minimal flow demonstrating the issue & someone will help you out.
Note: it is important to surround your code/flow with three backticks
```
like this
```
See this post for more details - How to share code or flow json