JavaScript conversion

Converting to JavaScript!!!