Question | Click to View Answer |
What does the following code print to the console? const path = require('path');
const r = path.normalize("/animals//lion.jpg");
console.log(r);
|
"/animals/lion.jpg" is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.normalize("/animals/cats/small/..");
console.log(r);
|
"/animals/cats" is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.join("/users", "phil", "/funny//pics/");
console.log(r);
|
"/users/phil/funny/pics/" is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.join("superheros", "x_men");
console.log(typeof(r));
|
"string" is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.dirname("/cities/east_coast/new_york.txt");
console.log(r);
|
"/cities/east_coast" is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.basename("/cities/midwest/kansas_city.txt");
console.log(r);
|
kansas_city.txt is printed. The |
What does the following code print to the console? const path = require('path');
const r = path.extname("/cities/images/seattle.jpg");
console.log(r);
|
.jpg is printed. The |
What does the following code print to the console? const fs = require('fs');
fs.exists('/etc/passwd', function(exists) {
if (exists) {
console.log("File exists!");
} else {
console.log("File doesn't exist :(");
}
});
|
"File exists!" is printed. The |
What does the following code print to the console? const fs = require('fs');
fs.exists('/something_crazy', function(exists) {
if (exists) {
console.log("File exists!");
} else {
console.log("File doesn't exist :(");
}
});
|
"File doesn't exist :(" is printed. |