All quizzesEasy
Core Modules & CLI — Series 2
Preview — 3 of 10 questions
Assume this script is run as: node script.js hello world. What is logged?
javascript
console.log(process.argv.length);
console.log(process.argv[2]);
console.log(process.argv[3]);A4, "script.js", "hello"
B4, "hello", "world"
C2, "hello", "world"
D2, "script.js", "hello"
What is logged?
javascript
const fs = require('fs');
fs.writeFileSync('notes.txt', 'Hello Node');
const content = fs.readFileSync('notes.txt', 'utf8');
console.log(content);
console.log(typeof content);A<Buffer 48 65 6c 6c 6f 20 4e 6f 64 65>, "object"
B"Hello Node", "object"
C"Hello Node", "string"
Dundefined, "undefined"
What is logged?
javascript
const path = require('path');
const filePath = '/home/user/documents/report.pdf';
console.log(path.basename(filePath));
console.log(path.extname(filePath));
console.log(path.join('folder', 'subfolder', 'file.txt'));A"report", ".pdf", "folder/subfolder/file.txt"
B"report.pdf", "pdf", "folder/subfolder/file.txt"
C"report.pdf", ".pdf", "folder/subfolder/file.txt"
D"/home/user/documents/report.pdf", ".pdf", "folder/subfolder/file.txt"
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.