Nice! can you rewrite this code in javascript