functions using js
Used a do while loop