parse inputs method in JavaScript