conditions added to JS homework2