Resolve User Home Path
NodeJS
Easy
3 views
Problem Description
Join a filename into the user home directory and print it.
Input Format
stdin: filename.
Output Format
Print resolved path.
Sample Test Case
Output:
C:\\\\Users\\\\...\\\\meetcode.txt
Constraints
Use os.homedir.
Official Solution
const fs = require('fs');
const os = require('os');
const path = require('path');
const name = fs.readFileSync(0, 'utf8').trim();
if (!name) process.exit(0);
console.log(path.join(os.homedir(), name));
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!