i want to create a text file from a string. currently i am using a function which takes an array and makes it into a string then using that string i want to create a local t
Convert your object to a JSON string.
var json_string = JSON.stringify(object, undefined, 2);
Notes:
, undefined, 2.Create a download link and click it:
var link = document.createElement('a');
link.download = 'data.json';
var blob = new Blob([json_string], {type: 'text/plain'});
link.href = window.URL.createObjectURL(blob);
link.click();