MCQs > IT & Programming > Node.js > A Node.js application consists of an HTML file named ‘idx.html' and a JavaScript f‌ile 'ht3.js'. The f‌ile ht3.js when executed, should display the content of 'idx.html' file on the web browser. However, the f‌ile 'ht3.js' contains some errors. Identify which code lines contain an error. 1. var http = require(‘http'); 2. var fs; 3. function send404(response){ 4. response.writeHead(404. ['Content—Type' :‘text/plain'}); 5. response.write('Error 404: Resource not found'); 6. response.end0: 7. } 8. var server =http.createServer(function(req. res)[ 9. if(req.method = 'GET', req.url =‘/')[ 10. res.writeHead(200, ['content-type' : 'text/html'}); 11. fs.createReadStream('idx.html') 12. ] 13. else[ 14. send404fres); 15. ] 16. ]).listen(3000); 17. console.logf'server running on port 3000');

Node.js MCQs

A Node.js application consists of an HTML file named ‘idx.html' and a JavaScript f‌ile 'ht3.js'. The f‌ile ht3.js when executed, should display the content of 'idx.html' file on the web browser. However, the f‌ile 'ht3.js' contains some errors. Identify which code lines contain an error.


1. var http = require(‘http');


2. var fs;


3. function send404(response){


4. response.writeHead(404. ['Content—Type' :‘text/plain'});


5. response.write('Error 404: Resource not found');


6. response.end0:


7. }


8. var server =http.createServer(function(req. res)[


9. if(req.method = 'GET', req.url =‘/')[


10. res.writeHead(200, ['content-type' : 'text/html'});


11. fs.createReadStream('idx.html')


12. ]


13. else[


14. send404fres);


15. ]


16. ]).listen(3000);


17. console.logf'server running on port 3000');


Answer

Correct Answer:

14

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Node.js Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Node.js Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it