solution using javascript and node.js