Question: Basically, I am not sure if AlertMessage is a callback function or not? Question 4 1 pts In JavaScript, a callback is a function passed


Basically, I am not sure if AlertMessage is a callback function or not?
Question 4 1 pts In JavaScript, a callback is a function passed into another function as an argument to be executed later. In Task 2, which function(s) is/are executed as a callback function? O alert Message() O readdir) O Both alert Message() and readdir() None 1 2 3 4 5 module. e Press Esc to exit full screen dirSortca Tunction ton (dir, tallback) { var fs=require('fs') fs.readdir(dir, function(err, data) { if(err) { callback(err,dir); } else { callback(null,dir, data.sort()); } 6 7 8 9 10 11 }); 12 } }; 13 Editing the call2.js to update the alertMessage function as follows; 1 function alertMessage(err, folderName, data) { 2. if(err) { 3 console.log('Error in reading folder ''+folderName+'"); 4 } else { console.log('List files in folder ''+folderName+'\' after sorting: '+JSON.stringify(data)); 5 6 } } 7 8 9 10 11 12 13 var lib=require('./myLib) lib.dirSorted('folder', alertMessage); lib.dirSorted('folder-2', alertMessage)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
