0

I'm trying to put a variable as ${Y} in but in the output I got (how can I write variable ${Y}) instead of the data in Y is someone have any solution?

const fs = require('fs');
const Y = fs.readFileSync('./txt/input.txt','utf-8')

const Z='how can i write variable ${Y}';
fs.writeFileSync('./txt/output.txt',Z);
console.log('File written!');
falinsky
  • 7,229
  • 3
  • 32
  • 56
Hossam Thapet
  • 129
  • 1
  • 6

1 Answers1

1

You should use a template literal instead of just a string (backticks instead of single quotes):

const Z=`how can i write variable ${Y}`;
falinsky
  • 7,229
  • 3
  • 32
  • 56