Updated sample code format, removed tailing whitespaces.
Changed sample snippet for JavaScript.