[Code] Hello World! NodeJS

·

1 min read

References : https://nodejs.org/dist/latest-v16.x/docs/api/

Hello World.

index.js

const hello = 'Hello world';
console.log(hello);

Read File System.

const fs = require('fs');
const textIn = fs.readFileSync('./txt/motivation.txt', 'utf-8');
console.log(textIn);

Write File System.

const fs = require('fs');
const textIn = fs.readFileSync('./txt/motivation.txt', 'utf-8');
console.log(textIn);

const textOut = This is what I know about the motivation: ${textIn}.\nCreated on ${Date.now()};fs.writeFileSync('./txt/output.txt', textOut);console.log('Create new file');