updated JS to handle snippets for JavaScript and Java