exercise4.rb added alternate solution using ternary operator