It is always easy to spend someone else's money, but for a going on 12-year old iMac I would suggest replacement. A sudden power loss seems to indicate something other than "wrong with your operating system". Also, I found the following about 21.5" iMacs:

"… Apple said the 21.5-inch and 27-inch ‌iMac‌ from Late 2013, the Mid 2014 21.5-inch ‌iMac‌, and the Retina 5K 27-inch ‌iMac‌ from late 2014 will be marked as obsolete on November 30, 2022. When marked as an obsolete product, the iMacs will no longer be eligible for any repairs and services."

How about a newer-ish laptop? Also check out Apple's refurbished section in the Apple Store online. They warrant the products as if they are new.