Generate a Text File with Data using Only Javascript

let a = document.createElement('a');
a.href = "data:application/octet-stream,"+encodeURIComponent("My DATA");
a.download = 'abc.txt';
a.click();

Change abc.txt to the filename you want to use.
Change MY DATA to the data you want to change.

Everything else can be left alone.