javascript version
adding tags describing the concepts praticed with the question.
renaming