Improve JavaScript function snippets.