Complete the code to import the 'path' module in Node.js.
const path = require('[1]');
The path module is a built-in Node.js module used for handling file paths. You import it using require('path').
Complete the code to get the file extension from the filename.
const ext = path.[1]('example.txt');
The extname method returns the extension of a file path, including the dot.
Fix the error in the code to correctly get the extension of 'archive.tar.gz'.
const extension = path.[1]('archive.tar.gz');
The extname method returns the extension including the last dot and characters after it. For 'archive.tar.gz', it returns '.gz'.
Fill both blanks to get the extension of a file path stored in variable 'filePath'.
const ext = path.[1]([2]);
Use path.extname(filePath) to get the extension of the file path stored in filePath.
Fill all three blanks to extract the extension and check if it equals '.js'.
const ext = path.[1](filename); if (ext === [2]) { console.log('This is a JavaScript file.'); }
Use path.extname(filename) to get the extension, then compare it to the string '.js' to check if the file is a JavaScript file.