Fix duplicate definition and scope in JavaScript

Fix code that makes JSHint issue duplicate definition
and use out of scope warnings.

Change-Id: I5a112a4bfc46b84ce3deb4e58c548aa6d8b8ae54
Implements: blueprint js-coding-style-checks
Merge "Fix duplicate definition and scope in JavaScript"