exercise #8 JS updated as per reviewers comment