Completed Funtional JavaScript