Solutions 3A

NOTE: there are other solutions that work. These are just our proposed solutions.

E1: Mumble jumble

def jumble(sentence)
  sentence.split("").shuffle.join("")
end

def mumble(sentence)
  sentence.downcase
end

E2: Scope It Out

  1. 20
  2. Assigns variable named loudness to integer 20, prints string "IT's SO LOUD", evaluates loudness local variable and returns 20
  3. 10, because it was assigned outside of the method it is unchanged by the method's local variable that shares the same name.

E3: A Better Bouncer

def lenient_bouncer
  true
end

def bouncer(age, country)
  if age.to_i >= 18 && country.downcase == "south africa" || age.to_i >= 21 && country.downcase == "usa"
    "You in"
  else
    "You out"
  end
end

def strict_bouncer(group, letter)
  accepted = []
  group.each do |first_name, age|
    if first_name[0].downcase != letter.downcase && age >= 21
      accepted << first_name
    end
  end
  accepted
end

## BONUS: If you're curious, look up the '.reduce' method.
## Can you use '.reduce' to make strict_bouncer more efficient?