Answer the question
In order to leave comments, you need to log in
How to save console.log to a separate file?
This is the code that needs to be saved in a separate file (more precisely, the output to the console)
const uuid = _ => 'xxx_xxx_00_00'.replace(/x|0/g, v => v === 'x'
? String.fromCharCode(Math.floor(Math.random() * 26) + 97)
: Math.floor(Math.random() * 10))
console.log(uuid());
PS D:\bat> node gg.js
lcn_ljo_13_77
Answer the question
In order to leave comments, you need to log in
const fs = require('fs')
const uuid = _ => 'xxx_xxx_00_00'.replace(/x|0/g, v => v === 'x'
? String.fromCharCode(Math.floor(Math.random() * 26) + 97)
: Math.floor(Math.random() * 10))
fs.appendFileSync('code.log', `${uuid()}\n`);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question