Skip to content
Snippets Groups Projects
Commit 28b98a03 authored by Sandeep Jha's avatar Sandeep Jha
Browse files

first commit

parent 27a40064
Branches master
No related tags found
No related merge requests found
index.js 0 → 100644
const fs =require('fs/promises')
let counter =1
let myFiles = `new${counter}.html`
//create Promise
const pro = new Promise((resolve,reject)=>{
resolve('Hello World')
reject('error occured')
}).then((res)=>{
console.log(res)
}).catch((err)=>{
console.log(err)
})
//create new file
async function readingDirectory() {
const fileNames = await fs.readdir(__dirname);
counter = fileNames.length+1
myFiles = `new${counter}.html`
const html = `<h1> hello ${counter}</h1>`
await fs.appendFile(__dirname+'/'+myFiles,html,)
}
readingDirectory().then(() => {
console.log(`file created${myFiles}`);
}).catch(err => {
console.log(err);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment