Is all the above true?

Then yes, your JavaScript works.

Probably.