That means there is no malware installed on your Mac. What you saw was a fake website with fake message. Your Mac is not infected with anything which is good news. These usually comes from online ads, adult websites, click-bait messages like "you won iPad", "free gift cards" etc. Never click on these kind of messages and never install apps that you don't trust.
There might be still the files of that message stored on your Mac. So I'd recommend you to clear your Safari to get rid of old internet files and this will clear the scam files as well. Click on Safari menu and select Clear History and Website Data. On the dropdown next to Clear, select All History and click Clear History.
If you ever see this message again, then force quit Safari, open it by holding down Shift key and clear Safari. That is all it needed. Also make sure you do regular software updates from Apple > App Store > Updates or Apple > Software Updates.
If you have any questions or would like any additional information, please don't hesitate to ask.
If you are satisfied with my service, please rate me as Good or Excellent Service (4 or 5 stars) and click Submit at the top. Then only I will get credit for helping you.
Also, add a bookmark of this page or add this page to your favorites, so if it happens again you can get back to me directly via that bookmark without paying again.