Professional Documents
Culture Documents
Roll No: 48
Assignment No. 1
Output:
Assignment No. 1
.editor Enter editor mode
.exit Exit the REPL
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
Write a Node.js code to print all even numbers in between 22 and 42 inclusive of
both if they are even.
Code:
> for ( a = 22; a<=42; a++){
Assignment No. 1
Output:
3. Write a Node.js code to solve the expression (x+y) 2 using functions. Execute in
REPL or Command prompt.
Code:
function s(x,y){
... return a=(x+y)**2;
... }
s(4,6);
Output:
100
4. Create a HTTP server to display your basic information Name, Age and Address on
the client.
Code:
Output:
Assignment No. 1
5. Create a module that will display the current date and time along with a concatenated
message, once the client tries to access the HTTP server.
Code:
Output:
6. Write a Node.js code to accept a query string from the user on the server through the
URL, and write it back to the client.
Code:
Assignment No. 1
Output:
7. Write a Node.Js code to pass specific input variables through the URL to the server
and the server should process then ad respond back.
Code:
Output:
8. Write a Node.js code to display your short Bio-Data (along with Photograph) saved in an
HTML file in response to the client’s access request to the server.
Code:
Assignment No. 1
Assignment No. 1
var fs = require('fs');
res.write(data);
return res.end();
});
}).listen(7777);
Output:
Assignment No. 1