JSFiddle - React, Tailwind, and code Playground

JavaScript

var blob = new Blob(["111111\n2222222\n333333"], { type: "text/plain" });
download(blob, "test.txt");

function download(blob,filename){
	if(typeof blob == "object"){
		if(window.navigator.msSaveBlob)
			return window.navigator.msSaveBlob(blob,filename);
		blob=window.URL.createObjectURL(blob)
	}
	var s=document.createElement("a");
	s.href=blob,
	s.download=filename,
	document.body.appendChild(s),
	s.click(),
	setTimeout(function(){
		window.URL.revokeObjectURL(blob);
		document.body.removeChild(s);
		s.remove();
	}, 300);
}