Home > Enterprise >  Node.js: Inline JS expression not parsing
Node.js: Inline JS expression not parsing

Time:04-03

I am using NodeJS v16.14.2

I am a beginner and was trying to write a simple text with inline JS expressions embedded into a file. However, those expressions are not parsing:

Here's the code:

***const fs = require('fs');
const textIn = fs.readFileSync('./txt/input.txt', 'utf-8');
console.log(textIn);
const textOut = 'This is what we know about avocados: ${textIn}. \nCreated on ${Date.now()}';
fs.writeFileSync('./txt/output.txt', textOut);
console.log('The file has been written');
console.log(textOut);***

Here's the output: The avocado

  • Related