create file fs code example
Example 1: fs writefile node
const fs = require('fs')
const content = 'Some content!'
fs.writeFile('/Users/joe/test.txt', content, err => {
if (err) {
console.error(err)
return
}
})
Example 2: fs create or edit file
const fs = require('fs');
fs.appendFile(‘<fileName>’,<content>,callbackFunction)
Example 3: javascript write to file
<script>
const fs = require('fs')
let data = "Learning how to write in a file."
fs.writeFile('Output.txt', data, (err) => {
if (err) throw err;
})
</script>