Resolve User Home Path

Resolve User Home Path

Easy NodeJS File System & Paths 40 views
Explanation Complexity

Problem Statement

Join a filename into the user home directory and print it.

Input Format

stdin: filename.

Output Format

Print resolved path.

Example

meetcode.txt
C:\\\\Users\\\\...\\\\meetcode.txt

Constraints

Use os.homedir.

Input / Output Format

Input Format
stdin: filename.
Output Format
Print resolved path.
Constraints
Use os.homedir.

Examples

Input:
meetcode.txt
Output:
C:\\\\Users\\\\...\\\\meetcode.txt

Example Solution (Public)

NodeJS
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));

Official Solution Code

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));
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.