Can we create a new file with code?

I am wanting to know how can I make a new file by javascript in my project. And how to type something in that.

Hey @4-AK,

You can use the fs module to create and edit files using JavaScript. Here’s how:

const fs = require('fs');

fs.writeFile('script.js', 'FILE_CONTENT', function (err) {
  if (err) throw err;

Note that fs.writeFile rewrites the whole content in a file. Use fs.appendFile to add contents to existing file contents.

Hope this helps!

thank you very much sir.

You’re welcome, but please don’t call me ‘sir’. :grin::joy: Just a regular thirteen year old boy!

lol i can see the awkwardness in here