You are thinking of the wrong books. The Hobbits are in the Lord of the Rings trilogy, not Harry Potter, and yes they win at great cost.
Harry wins also.
Actually, “The Hobbit” was a book before the continuation (”The Lord of the Rings”)..
I read “The Hobbit starting in the 3rd grade.. can’t even remember how I picked it up (found it).. I7ve read it at least 5 times... and starting in the 4th grade, I started reading “The Lord of the Rings”.. (reading it again now, as a matter of fact..) .. I’ve read TLOTR at least 30 times..
anyway :p