Skip to content

Conversation

@cmhorsey
Copy link

@cmhorsey cmhorsey commented Jul 9, 2024

Practiced using common enumerable methods like #map, #find, #filter, and #sort.

def print_spicy_foods(spicy_foods)
# your code here
spicy_foods.each do |food|
heat = "🌶" * food[:heat_level]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this.

Comment on lines 47 to 53
def average_heat_level(spicy_foods)
# your code here
heat_levels = spicy_foods.map do |food|
food[:heat_level]
end
average_heat = heat_levels.sum / heat_levels.length
average_heat
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch your indentation

Comment on lines +48 to +52
heat_levels = spicy_foods.map do |food|
food[:heat_level]
end
average_heat = heat_levels.sum / heat_levels.length
average_heat

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another way this could be done. Ruby is great!

Suggested change
heat_levels = spicy_foods.map do |food|
food[:heat_level]
end
average_heat = heat_levels.sum / heat_levels.length
average_heat
total_heat = spicy_foods.sum do |food|
food[:heat_level]
end
total_heat / heat_levels.length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants