Fix variable assignment in docs example (#80418)
### What?
Fixes small bug in Javascript code example where same variable is
declared again.
### How?
Same as this PR #74744 which fixed the Typescript code.
Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>