Solution: Check Your Directory

Exercise solution to "Check Your Directory" where the solution leverages asynchronous programming, promises, and async functions

We'll cover the following

Solution

For the solution of the exercise, use the file reading function fs.readFile. Wrap it inside a promise to use it inside our async function. In our callback of the fs.readFile function, call resolve function if an error does or does not occurs, and supply it an array with the file name and boolean value. This makes each file name its own promise and uses the Promise.all function to resolve all of them together, along with the await token. See the solution below.

Get hands-on with 1400+ tech skills courses.