Mid-Level
August 19, 2026

Spot the bug: Ruby on Rails

One snippet. Find the bug, or prove there isn't one.

ruby
1class CartCalculator
2  def total_with_discount(items, discount_rate)
3    subtotal = items.sum(&:price)
4    discount = subtotal * discount_rate
5    subtotal - discount
6  end
7end

Click the lines that carry the problem.

Your verdict

One attempt per day. The answer shows up right after.

Keep your streak

Create an account to keep your streak and track your progress.

Create an account