Untitled
unknown
javascript
a year ago
958 B
6
Indexable
const fs = require('fs'); const exec = require('child_process').exec; // Create a new file fs.writeFileSync('newfile.txt', 'This is some content for the new file.'); // Function to list files and format output function listFiles() { exec('ls', (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`); return; } // Split the output into an array of filenames let files = stdout.split('\n').filter(Boolean); // Join filenames with comma and space let output = files.join(', '); // Concatenate with challengeToken let challengeToken = 'un7abce1'; output += challengeToken; // Replace every fourth character with an underscore output = output.split('').map((char, index) => (index + 1) % 4 === 0 ? '_' : char ).join(''); console.log(output); }); } // Call the function listFiles();
Editor is loading...
Leave a Comment