Quotes help make search much faster. Example: "Practice Makes Perfect"

Monday, December 17, 2012

LearnStreet Sample Solution to Lesson 7 Exercise 8



# Your function should return:
# 1. The string "1 - 50" if the number is between 1 to 50
# 2. The string "51 - 100" if the number is between 51 to 100
# 3. The string "101 - 200" if the number is between 101 to 200
# 4. The string "greater than 201" if the number is greater than 201

def get_range(number)
    #your code here
    if number >= 1 and number <= 50
        "1 - 50"
    elsif number >= 51 and number <=100
        "51 - 100"
    elsif number >= 101 and number <=200
        "101 - 200"
    elsif number >= 201
        "greater than 201"
    else
        "zero or negative numbers aren't allowed"
    end
end

get_range(70)

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts