Skip to content

Instantly share code, notes, and snippets.

@barnes7td
Created November 30, 2016 20:56
Show Gist options
  • Save barnes7td/0839d08cd1530859d1633870c41f36d2 to your computer and use it in GitHub Desktop.
Save barnes7td/0839d08cd1530859d1633870c41f36d2 to your computer and use it in GitHub Desktop.
# INSTRUCTIONS:
# Create a function named createArray. This function should:
# 1. Define a method named countries_visited.
# 2. The method should return an Array of the countries in alphabetical order..
# 3. The method should return an Array without duplicate values.
# Tests Given:
describe "countries_visited" do
it "returns a unique list of sorted countries if the array has elements" do
arr = ["USA", "USA", "France", "Scotland"]
expect( countries_visited(arr) ).to eq(["France", "Scotland", "USA"])
end
it "returns a unique list of sorted countries if the array has elements" do
arr = ["USA", "Germany", "Denmark", "Germany"]
expect( countries_visited(arr) ).to eq(["Denmark", "Germany", "USA"])
end
end
# Starting Code:
def countries_visited
end
# Current Answer:
def countries_visited(countries)
countries = ["France", "Scotland", "USA"]
return countries
}
countries_visited(["USA", "USA", "France", "Scotland"])
# Student: I can pass 1 test, but not both. What am I doing wrong?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment