FSD-2_Practice Book_2024
FSD-2_Practice Book_2024
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
1 1 In the JSON syntax, data is separated by _____. Commas 0.5 Semicolons Colons Commas Hyphens
{ "days" : [ "SUN" , "MON" , "TUE" , [ "days" : { "SUN" , "MON" , "TUE" , "WED" , "THU" , [ "days" : { SUN , MON , TUE , WED , { "days" : { "SUN" , "MON" , "TUE" , { "days" : [ "SUN" , "MON" , "TUE" , "WED" ,
4 1 How do you represent a JSON array of strings? 1
"WED" , "THU" , "FRI" , "SAT" ] } "FRI" , "SAT" } ] THU , FRI , SAT } ] "WED" , "THU" , "FRI" , "SAT" } } "THU" , "FRI" , "SAT" ] }
5 1 Which of the following code will throw an error? JSON.parse(undefined); JSON.parse(false); JSON.parse(null); JSON.parse(undefined); JSON.parse(0); JSON.parse(1); both (a) and (c)
6 1 Which of the following JSON values cannot be one of the following data types? function 0.5 a number a string a function null
JavaScript has a___________________ built in function for converting an object
7 1 JSON.stringify() 0.5 JSON.parse() JSON.stringify() JSON_Parse () JSON_Stringify()
into a JSON string:
JavaScript has a_________________ built in function for converting JSON strings
8 1 JSON.parse() 0.5 JSON.parse() JSON.stringify() JSON_Parse () JSON_Stringify()
into JavaScript objects
9 1 The extension and MIME type for JSON text is .json & application/json 0.5 .json & application/json .js & application/json .json & text/js .js & text/json
const person=
{
name:"xyz",
age:28,
employee:
[{
emp_name:"pqr",
designation:"prof",
console.log(person.employee[0].weekly_ console.log(person.employee[0].weekly_ console.log(person.employee[0].weekly console.log(person.employee[1].weekly_lec.lengt console.log(person.employee.weekly_le console.log(person.employee[1].weekly_
12 1 weekly_lec:["Tuesday"] 1 console.log(person.employee[0].weekly_lec.length);
lec.length); lec.length()); _lec[0].length); h); c[0].length); lec.length());
},
{
emp_name:"jkl",
designation:"Asst prof",
weekly_lec:["Friday","Saturday"]
}]
}
Identify the correct statement to print no. of weekly lectures of “pqr” employee.
20 1 Which of these is an example of a proper JSON array? { "students": ["Sita", "Rita", "Gita"] } 0.5 { students= ["Sita", "Rita", "Gita"] } { "students": ["Sita", "Rita", "Gita"] } { "students": [{"Sita", "Rita", "Gita"]} } { students: ["Sita", "Rita", "Gita"] } { ‘student’: [{"Sita", "Rita", "Gita"]} } { "students": ["Sita", "Rita", "Gita"}]
21 1 Which of the following is the correct syntax to create JSON Boolean object? {"name":true/false} 0.5 {name:true/false} {"name"=true/false} {'name':true/false} {"name":true/false} {name:{true/false}} {name:[true/false]}
24 1 Write a script of JSON array containing objects and display the same in console. 2
Write a JSON script by entering user detail of three different person having same
25 1 age group in string format method. Print the following result in object form. (1) 2
User Details (2) Name of 2nd person and his/her age.
Write a JSON script to store information related to books based on their id,
26 1 2
topic,edition and author. (Minimum details of three books having id=1,2,3)
Write a function 'FirstAndLast' that takes in an array, and returns an object with:
1) the first element of the array as the object's key, and
27 1 2) the last element of the array as that key's value. 3
(Example input: ['ABC', 'DEF', 'Employee', 'Manager']
output: ABC : 'Manager')
Write a JSON script to display array of objects using for in loop as per table.
28 1 3
Write a JSON script to define Name,DOB,Age and birthplace of one person. Then
29 1 3
print his birthdate in console as well as in chrome after clicking birthdate button.
Write a script to define two JSON objects named as “division1” and “division2”
30 1 having an array to store 5 names of students along with their roll number and list 3
of subjects they opted.
Write a JS to store an array of objects having height and name. display name and
31 1 3
height of person with highest height.
Write a script to define two JSON objects named as “division1” and “division2”
having an array to store names of students. These name should be sorted
32 1 5
alphabetically in the object and should be be written to the file. At last, both
division objects should be visible with names sorted alphabetically in file.
Write a JSON object which contains array of 3 objects. Each object contains 2
33 1 properties name and age. Now, sort an array values by age in descending order. 5
Print name in terminal as per the sorted age.
Write one JSON string with date property (yyyy-mm-dd) and print date in India
34 1 5
standard time.
Create a JSON object named Home Expenses in which you have to add monthly
35 1 expenses of transport , food bill and names of different family members including 3
mother,father,brother and sister.Print the expenses of father with his name.
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
Write a script to define two JSON objects named as “division1” and “division2”
having an array to store 5 integer numbers. Write this object in a file named
XYZ.txt using file system. Define third array as result which gives output as
36 1 explained below: Suppose first array contains base value and second array contains 3
power value and then third array will give output as: a^b.For example: first
array[0]=2 and second array[0]=3 then it should return 8 in third array[0] .Also
append this result in XYZ.txt and as well as on console.
Below JSON object a is given. Print below sentence in console from the given
object.
Hi ! We are students of LJU .
Exam - FSD2
const a = {
"A" : "LJU",
"B" : ["CSE", { 'M' : [ { "N" : "FSD2" } , "Exam" ]}],
37 1 3
"C" : [ {
"D" : "Hi",
"E" : ['are', 4, {'F' : ['semester', 'We']} ]
}],
"G" : {"H" : "students", "I" : ["of","!"] },
"J" : [{"K" :".", "L":"-"},"FSD-2"]
}
39 2 Which of the following is an advantage of using Node.js? It has a non-blocking I/O model 1 It is a statically typed language It is a compiled language It has a large standard library It has a non-blocking I/O model
40 2 which function is used to include modules in Node Js. require() 0.5 include(); require(); attach(); None of the above
Ctrl + B
41 2 Which of the following shortcut command is used to kill a process in Node.js? Ctrl + C 0.5 Ctrl + K Ctrl + T Ctrl + C
45 2 _____ is an interactive shell that processes Node. REPL 0.5 REAL REPL RESP RPEL
It is used to get the last command that
46 2 Underscore (_) variable in REPL session of NodeJS is used for? It is used to get last result 1 It is used to store result It is used to get last result It is used to print result
was used
Which statement is true for following code?
function myFunc(arg) arg was =>funky , will show after 1 arg was =>funky , will show 1000 times after the arg was =>funky , will show till 1000 arg was =>funky , will show arg was =>funky , will show after 1
47 2 1 undefined null
{ console.log(`arg was => ${arg}`); second of program run program run miliseconds after the program run immediately the program run second of program run
setTimeout(myFunc, 1000,'funky');
Which statement is true for following code? HELLO GEEK , will print infinite time HELLO GEEK , will print one time HELLO GEEK , will print 1000 time HELLO GEEK , will print infinite time after 1
48 2 1 HELLO GEEK , will print 1000 times
setInterval(() => {console.log('HELLO GEEK');}, 1000); after 1 second after 1000 miliseconds after 1 second second
var pm=require("path"); var pm=require("path"); var pm=require("path");
path1=pm.dirname("D:/ABC/DEMO/abc path1=pm.dirname("D:/ABC/DEMO/ab path1=pm.dir("D:/ABC/DEMO/abc.txt
var pm=require("path"); var pm=require("path");
.txt"); c.txt"); ");
path1=pm.dir("D:/ABC/DEMO/abc.txt"); path1=pm.directory("D:/ABC/DEMO/abc.txt");
Identify the correct code which produces following output. console.log(path1); console.log(path1); console.log(path1);
console.log(path1); console.log(path1);
D:/ABC/DEMO path2=pm.extname("D:/ABC/DEMO/ab path2=pm.extname("D:/ABC/DEMO/ab path2=pm.ext("D:/ABC/DEMO/abc.txt
49 2 1 path2=pm.extension("D:/ABC/DEMO/abc.txt"); path2=pm.extension("D:/ABC/DEMO/abc.txt");
.txt c.txt"); c.txt"); ");
console.log(path2); console.log(path2);
abc.txt console.log(path2); console.log(path2); console.log(path2);
path3=pm.base("D:/ABC/DEMO/abc.txt"); path3=pm.file("D:/ABC/DEMO/abc.txt");
path3=pm.basename("D:/ABC/DEMO/a path3=pm.basename("D:/ABC/DEMO/a path3=pm.base("D:/ABC/DEMO/abc.t
console.log(path3); console.log(path3);
bc.txt"); bc.txt"); xt");
console.log(path3); console.log(path3); console.log(path3);
50 2 Which of the following is used to create a new HTTP server in Node.js? http.createServer() 1 http.createServer() http.createServer http.newServer() http.newServer
Identify the equivalent code of given code snippet which produces same Output. var pm=require("path"); var pm=require("path");
var pm=require("path"); var pm=require("path");
var pm=require("path"); var pm=require("path"); var pm=require("path"); var path="D:/abc/def/jkl/some.txt"; var pm=require("path"); var path="D:/abc/def/jkl/some.txt";
var path="D:/abc/def/jkl/some.txt"; var path="D:/abc/def/jkl/some.txt";
var path="D:/abc/def/jkl/some.txt"; var path="D:/abc/def/jkl/some.txt"; var path="D:/abc/def/jkl/some.txt"; var ans=pm.parse(path); var path="D:/abc/def/jkl/some.txt"; var ans=pm.parse(path);
var ans=pm.parse(path); var ans=pm.parse(path);
52 2 var ans=pm.basename(path); var ans=pm.parse(path); 1 var ans=pm.parse(path); console.log("Filename=" var ans=pm.parse(path); console.log("Filename="
console.log("Filename=" +ans.filename); console.log("Filename=" +ans.file);
var sep=ans.split("."); console.log("Filename=" +ans.name); console.log("Filename=" +ans.filename); +ans.filename); console.log("Filename=" +ans.name); +ans.basename);
console.log("Extension=" console.log("Extension="
console.log("Filename="+sep[0]); console.log("Extension=" +ans.ext); console.log("Extension=" +ans.ext); console.log("Extension=" console.log("Extension=" +ans.ext); console.log("Extension="
+ans.extension); +ans.extension);
console.log("Extension="+"."+sep[1]); +pm.extname(path)); +ans.extention);
Which is the correct code for following output: var os=require("os"); var os=require("os"); var os=require("os"); var os=require("os"); var os=require("os"); var os=require("os"); var os=require("os");
UGC_31 console.log(os.hostname()); console.log(os.host()); console.log(os.host()); console.log(os.hostname()); console.log(os.hostname()); console.log(os.hostname()); console.log(os.hostname());
54 2 x64 console.log(os.arch()); 1 console.log(os.arch()); console.log(os.arch()); console.log(os.arch()); console.log(os.arch()); console.log(os.architec()); console.log(os.architec());
win32 console.log(os.platform()); console.log(os.platform()); console.log(os.platform()); console.log(os.system()); console.log(os.platform()); console.log(os.system()); console.log(os.system());
C:\Users\UGC\AppData\Local\Temp console.log(os.tmpdir()); console.log(os.dirname()); console.log(os.tempdir()); console.log(os.tempdir()); console.log(os.tmpdir()); console.log(os.tmpdir()); console.log(os.dirname());
Idntify output of following statement.
55 2 console.log(pm.basename("D:/hello/abc/1.doc")); 1.doc 0.5 D:/hello/abc D:/hello/abc/1.doc 1.doc doc 1 D:
Where pm is an object of path module.
Identify error/output.
const fs=require("fs"); UTF-8 values of contents of abc.txt is ASCII values of contents of abc.txt is Error as toString() method is not called File system must be imported using
56 2 Syntax error 0.5 contents of abc.txt file is printed Syntax error
data=fs.readFile("abc.txt") printed printed for data import statement rather than require
console.log(data);
const h=require("http");
const obj=
{
name:"Demo",
age:33
}
57 2 Only (A),(B),(C) 1 JSON.stringify(obj) obj.toString() “”+obj obj All (A),(B),(C),(D) Only (A),(B),(C)
h.createServer(
(req,res)=>
{
res.end(_______________________);
}).listen(3000);
Fill in the blank in res.end() method, so that it would not generate an error.
Identify error/output.
function fun(x)
{
console.log(x++)
Prints 1,2,3…. Infinite every 3 seconds Error, as 3000 must be as 1st argument in Error, as callback is not required in Prints 1,1,1….Infinite time every 3
58 2 } Prints 1 after 3 seconds of delay 1 Prints 2 after 3 seconds of delay Prints 1 after 3 seconds of delay
of duration setTimeout() function setTimeout function seconds of delay
setTimeout(function()
{
fun(1);
},3000)
What will be the output of the following code ?
var pm=require("path");
ext = pm.extname("D:/LJ/abc.text")
if(ext == ".txt"){ Error:No such method named
59 2 Not a text Document 1 Text Document Not a text Document Error : No such method named require exists Error:ext is not defined Error:pm is not defined
console.log("Text Document"); extname() exists
}else {
console.log("Not a text Document");
}
What will be the output of the following program:
var data = {
"people": [
{ "name": "John", "age": 25 },
{ "name": "Jane", "age": 30 },
Jane Jane 20 John Mike 30
{ "name": "Mike", "age": 20 }
60 2 John 1 John 25 Jane John 25 NONE OF THE ABOVE
]
Mike Mike 30 Mike Jane 20
};
data.people.sort((a, b) => b.age - a.age);
data.people.forEach((person) => {
console.log(person.name);
});
What will be the output of the following code in console?
var ps=require("fs"); <Buffer 48 65 6c 6c 6f 20 21 20 48 6f <Buffer 48 65 6c 6c 6f 20 21 20 48 6f 77 20 61 Nothing will be given as output on
61 2 1 Hello ! How are you Error”Hello.txt” doesn’t exist null undefined
ps.writeFileSync("Hello.txt","Hello ! How are you !") 77 20 61 72 65 20 79 6f 75 20 21> 72 65 20 79 6f 75 20 21> console
ps.readFileSync("Hello.txt")
Which of the following functions is used to execute a function named fun on every
62 2 setInterval(fun,2000) 1 setInterval(fun,2000) setInterval(fun,2) setInterval(2000,fun); setTimeout(fun,2000); setTimeout(fun,2); setTimeout(2,fun);
2 seconds time interval?
Which of the following options correctly demonstrates the usage of the Path
63 2 path.basename("E:/abc/file.txt ") 0.5 path.fullname("E:/abc/file.txt") path.filename("E:/abc/file.txt ") path.filename("E:/abc/file.txt ") path.basename("E:/abc/file.txt ") path.name("E:/abc/file.txt ") path.extension("E:/abc/file.txt ")
module in Node.js to render only the filename including its extension?
Which of the following options demonstrates the correct usage of the fs.writeFileSync("data.txt", "Hello, fs.writeFileSync("data.txt", { message: fs.writeFileSync({ path: "data.txt" }, fs.writeFileSync({ path: "data.txt" }, { message: fs.writeFileSync("data.txt",
64 2 0.5 fs.writeFileSync("data.txt", "Hello, World!"); fs.writeFileSync("data.txt", 200);
fs.writeFileSync method in Node.js to write data to a file synchronously? World!"); "Hello, World!" }); "Hello, World!"); "Hello, World!" }); Buffer.from("Hello, World!"));
65 2 What does REPL stand for? read, eval, print, loop 0.5 run, examine, put, loop read, eval, print, loop run, edit, print, loop read, execute, print, loop read, eval, post, loop random, eval, package, loop
66 2 Which method is used to delete a file using the ‘fs’ module? fs.unlink() 0.5 fs.removeFile() fs.unlink() fs.delete() fs.removeFile() fs.unlinkRemove() fs.deleteFile()
67 2 How can you get the free memory of system using the ‘os’ module? os.freemem() 0.5 os.home() os.totalMemory() os.freemem() os.totalmem() os.Memory() os.systemMemory()
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
Which of the following options demonstrates the correct usage of the fs.readFile fs.readFile('file.txt', 'utf-8', (err, data) => fs.readFile('file.txt', 'utf-8', (err, data) => fs.readFile('file.txt', 'utf-8'); fs.readFile('file.txt', ‘this’,{ fs.readFile((file.txt, data) => { fs.readFile('file.txt', (read,write) => {
68 2 1 fs.readFile('file.txt', (data) => { console.log(file); });
method in Node.js to read a file asynchronously? { console.log(data) }); { console.log(data) }); console.log(read); console.log(file.txt[data]) }); console.log(data) }); console.log(data) });
What does the code shown below do?
const fs = require('fs');
const os = require('os');
const system = os.platform();
creates a text file hello.txt and appends
69 2 fs.appendFile('hello.txt', `Hello ${system}`, 1 creates a text file hello.txt and appends Hello win32 creates an image file file not create and shows the error creates a file named data and append numbers print content Hello on console D and E both
Hello win32
(err) => { if (err) throw err;
console.log('The data was appended to file!');
});
What will be the output of following code? In "Hello.txt" file "hello students" is
written.
var ps=require("fs");
var data=ps.readFileSync("Hello.txt"); Buffer Data Program ended Buffer Data hello students hello students Program ended Buffer Data
75 2 console.log(data); Program ended 1 hello students hello students Buffer Data Program ended Buffer Data Program ended
ps.readFile("Hello.txt",function(err,data){ hello students hello students Program ended Program ended hello students hello students hello students
if(err){return console.error(err); }
console.log(data.toString());});
console.log("Program ended");
76 2 Http module falls under which type of module? Core 0.5 Core Local Global Third party Secondary Primary
77 2 How do we get the filename portion of a path to the file in Node.js ? path.basename() 1 path.ext() path.basename() path.dirname() path.extname() path.filename() path.file()
What will be the output of the following code?
var ps=require("fs");
ps.writeFileSync("source.txt","Hello");
78 2 ps.writeFileSync("source1.txt","World"); World"Hello" 1 Hello World Hello World World"Hello" Hello"World" WorldHello
data=ps.readFileSync("source.txt","utf-8");
data2=JSON.stringify(data);
ps.appendFileSync("source1.txt",data2);
Write a Node.Js program to sort an interger array, where all element are available
79 2 3
in a file separated by white space. Print sorted array elements on node.js server.
Write Node.Js code that display "Hello" with incresing font-size in interval of 50
80 2 4
miliseconds in blue color. When font-size reaches to 50 pixel it should stop.
Write node.js script to copy content of one file to the other file. data should be
81 2 2
fetched from source.txt and insert to destination.txt
Write node.js script to print “Welcome Admin” on home page of server. If user
82 2 request for second page it display “This is second page” in italic font-style and if 4
any other request is requested it shows “Page not found” message.
Write a script to display sum of two numbers which are passed as an argument in
83 2 function named Total. the sum should display in any html element. Use callback as 3
third argument in Total function.
Write a script to define two JSON objects named as “division1” and “division2”
having an array to store names of students. These names should be sorted
84 2 2
alphabetically in the object and should be written to the file. At last, both division
objects should be visible with names sorted alphabetically in file.
Write a node.js script to write contents to the file in original manner. Delete file
85 2 3
after finishing writing
Write a node js script to write the text “You are creating a file” to help.txt file.
After that append the text “you are appending data” to same help.txt file. After that
read the file and print file contents on console. After finishing read operation ,
90 2 4
print the line “Thanks for using my program” on console. write ,append,read
sequence must be maintain. all read ,write and append operations are
asynchronous.
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
Write a node.js script to print 1st 10 prime numbers on browser in table of 10
91 2 rows. Odd no. of rows should render in blue color and even no. of rows should 5
render in red color.
Write a nodeJS script to print “My PC is on fire” on server at port no 5555 if
92 2 having more than 4gb physical available memory otherwise,”I need more more 4
memory” should get displayed.
Write a node.js script to write the text “This is data” to new.txt file. After that
append the text “That is data” to same new.txt file. After that read the file & print
93 2 the file content on console. After finishing read operation print the line “Thank you 5
for using program”. Write, append & read sequence must be maintained & all
operations are asynchronous.
Create HTTP webpages where Admin page display “Sufficient Memory:” in bold
blue color with font size of 24px along with available memory in GB with font
size 32px and red color if available physical memory of the system is greater than
95 2 5
1 GB.
Else it shows “Not Sufficient Memory” in simple text.
For any other page requested then shows “You are not admin” message.
Write node.js script to print “Welcome to Home Page” with two links containing
two pages named as “About Us” and “Contact Us” on home page of server. If user
request for About Us page it should display “Welcome to LJ University” in bold
98 2 3
font-style with blue color and if user request for Contact Us page it should display
“Email:abc@ljinstitutes.edu.in” in italic font-style with red color if any other
request is requested it shows “Page not found” message in plaintext.
106 3 Identify the correct validator module to validate correct email address. isEmail() 0.5 isEmail() isemail() isMail() ismail()
107 3 Which method is used to bind connection event with its handler? on() 0.5 emit() on() event() listeners()
111 3 Which NodeJS object specifies the name of the directory which contains the code? __dirname 0.5 Buffer __filename __dirname None of above
112 3 What function is used to fire an event? emit() 0.5 fire() calc() listner() emit()
113 3 How to make node modules available externally? module.exports 0.5 module.spread module.exports module.expose module.divide
Which module variable holds the resolved absolute path of the current module
114 3 __filename 0.5 __filename __pathname __location __flder
file?
exports, require, module, __filename, exports, require, module, __filename, export, require, module, __filename, export, required, module, __filename,
115 3 What are the arguments passed to the module wrapper function? 1 exports, process, require, module, __filename, __dirname exports, __filename, __dirname exports, module, __filename, __dirname
__dirname __dirname __dirname __dirname
functions, objects, arrays, or anything functions, objects, arrays, or anything you assign
116 3 What can you export with module.exports? 0.5 only objects only variables and arrays only functions
you assign to the module to the module
When an event emitter object emits an
The emit method allows a arbitrary set of arguments to be event, all of the functions attached to Any values returned by the listeners for an emitted
117 3 Which statement about event emitters is false? Event names must be camelCase strings. 1 Event names must be camelCase strings.
passed to the listener functions. that specific event are called events are ignored.
synchronously.
What will this code log to the console?
// File: student.js
exports.name = "ABC";
118 3 { name: 'ABC' } 0.5 { name: 'ABC' } {'ABC'} {} ABC
// File: index.js
const s = require('./student.js');
console.log(s);
Which statement will print “Welcome” in Red color, Underlined and with white console.log(ch.red.underline.bgWhite(" console.log(ch,red,underline,bgwhite("W console.log(red.underline.bgWhite("We console.log(ch.Red.UnderLine.bgWhite(Welcome console.log(Red.UnderLine.bg.White(W console.log(ch.red.underline.White.back
119 3 1 console.log(ch.red.underline.bgWhite("Welcome"));
background using chalk module in console. Welcome")); elcome")); lcome")); )); elcome)); ground("Welcome");
Which of the following class is used to create and consume custom events in
121 3 EventEmitter 0.5 Events NodeEvent Emit Eventemit EventEmitter On
Node.js?
122 3 Which of the following consider as NodeJS global objects? __filename 0.5 __file __dir __fileName __directory __filename __name
123 3 Something that happened in our application that we can respond too. events 0.5 actions callback methods procedures events function
import ch from "chalk"; import ch from "chalk"; import ch from "chalk"; import ch from "chalk"; import ch from "chalk"; import ch from "chalk"; import ch from "chalk";
import v from 'validator'; import v from 'validator'; import v from 'validator'; import v from 'validator'; import v from 'validator'; import v from 'validator'; import v from 'validator';
124 3 Identify the correct code to print output true in red color with bold & italic effect. 1
console.log(ch.red.bold.italic(v.isEmail(" console.log(ch.red.bold.italic(v.isemail("hello@gmail.co console.log(v.isEmail(ch.bgReg.bold.ital console.log(ch.red.bold.italic(v.isEmail console.log(ch.bgRed.bold.italic(v.isemail("hello console.log(ch.bgRed.bold.italic(v.isEm console.log(v.isEmail(ch.reg.bold.italic("
hello@gmail.com"))); m"))); ic("hello@gmail.com"))); ("hello@gmail.com"))); @gmail.com"))); ail("hello@gmail.com"))); hello@gmail.com")));
125 3 Which method of a class is called to initialize an object of that class? constructor() 1 new() class() create() init() constructor() object()
127 3 Identify correct command to install chalk module. npm install chalk 0.5 node install chalk node i chalk node install –g chalk npm install chalk npm module chalk npm module -chalk
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
Identify error/output
one.js
const c="ABC";
const add=(a,b)=>
{
return a+b;
}
Error, as all functions and constant must be fetched Error, as sequence must match to export
128 3 const sub=(a,b)=> 37,31,ABC 0.5 37,37,ABC 34,34,ABC ABC, 31,37 37,31,ABC
separate, not in object and require statements
{
return a-b;
}
module.exports={c,sub,add};
useOne.js
const obj=require("./one.js")
console.log(obj.add(34,3)+ ","+ obj.sub(34,3) +","+obj.c);
Identify error/output.
const h=require("events");
const ee=new h.EventEmitter();
const listener=()=>
{
console.log("Thanks")
Thanks
} Thanks Error, as event name need not passed in Error, as same event name cannot be
129 3 2 1 1 2 Bye
const listener2=()=> Bye listenerCount() function associated with two different listeners
2
{
console.log("Bye")
}
ee.on("hii",listener);
ee.on("hii",listener2);
console.log(ee.listenerCount("hii"));
130 3 Which Chalk method should be used to print the text "Hello" in bold green color? chalk.bold.green("Hello") 1 chalk.green("Hello") chalk.bold.green("Hello") chalk.boldGreen("Hello") chalk.boldGreen("Hello") chalk.bgGreen.bold("Hello") chalk.bold.bgGreen("Hello")
Identify Output:
var u=require("url");
131 3 var addr="http://localhost:8080/simple.html?day=monday&week=3"; ?day=monday&week=3 1 ?day=monday&week=3 simple.html?day=monday&week=3 simple.html TRUE .html syntaxerror
var q=u.parse(addr,true);
console.log(q.search);
132 3 How can you check the number of listeners for a specific event in Node.js? listenerCount() 1 getListenersCount() countListener() CountListen() listenerCount() count() listencount()
What will be the output of following? Hello will be displayed in yellow color "Hello" will be displayed in bold blue "Hello" will be displayed in bold "Hello" will be displayed in blue color Hello will be display in bold blue color
Hello will be displayed in yellow color with underline "Hello" will be displayed in blue color with
133 3 import ch from "chalk"; with underline and blue background 1 color with underline and yellow yellow color without underline and blue without without
and blue background color underline and yellow background color
console.log(ch.blue.underline.bgYellow("Hello")); color background color background color underline and blue background color underline and blue background color
Identify output:
red background color to the text red background color to the text
import ch from “chalk”; red background color to the text "hii" and red text red background color to the text red color to the text "Thanks" and red
135 3 "Thanks"and red text color to the text 1 red background color to the text "Thanks" red color to the text “hii”. "Thanks"and red text color to the text
console.log(ch.bgRed("Thanks")+ch.red("hii")); color to the text “Thanks” "Thanks" and “hii” text color to the text “hii”
“hii” “hii”
Write a node.js script to print query string of URL on console as well as on file
137 3 5
using ES6 Callback.
Write a node.js script to load a simple.html file on nodejs web server & prints its
138 3 5
contents as an html content.
Write a node.js script to find all prime no.s between 1-50 using external module
139 3 having a function checkPrime(). This function returns Boolean value on the basis 4
of a no. is prime or not prime. Write all necessary .js files.
Write a node.js script to create a class time & assign members hour, minute &
second. Create two objects of time class & add both the time objects so that it
144 3 should return is third time object. Third time object should have hour, minute & 5
second such that after addition if second exceeds 60 then minute value should be
incremented. If minute exceeds 60 then hour value should be incremented.
145 3 Explain node js own module with suitable example. Write necessary js file. 4
Write a node.js script to create calculator using external module having a function
148 3 add(), sub(), mul(), div(). This function returns result of calculation. Write all 4
necessary .js files.
152 3 Explain node js events with appropriate example with all event methods. 5
Calculate following series for given values of x and n. x and n are any positive
integers statically.
156 3 5
Ans=1-(x/1!)+(x2/2!)-(x3/3!)+…..+(xn/n!)
Create separate module function to compute factorial used in denominator.
Write a nodeJS script to fire an event named calculate which calculates the total
marks of 5 subjects about of 25 marks and displays the total marks on console as
157 3 5
an output.The calculate event fires another event name percentage which takes total
marks as argument and percentage should get displayed in console.
Write node.js script to create a file named “new.txt”. Now, check if available
158 3 memory of the system is greater than 1 GB then print message “Sufficient 5
Memory”in the file, else print message “Low Memory” in file.
Write a function that takes an array of numbers as input and returns the sum of all
159 3 2
the numbers in the array after 3 seconds.
Write node js script to fetch values from url given below and display output as
asked.
"https://www.google.com/exam.txt?c1=Hello&c2=FSD2+T1+Test&c3=
Welcome+to+LJU#AllTheBest"
1) Data must be written as below in file named “exam.txt”. File name must be
fetched from
the url given above.
161 3 Output: 5
Hello!
Welcome to LJU FSD2 T1 Test
#AllTheBest
2) Read content from file “exam.txt” and send response to server and display data
in “/” page
in same format as above but in H1 tag and in red color.
3) If any other page is requested it shows “Page not found” message in plain text.
unit mark
Sr.No
_no
question_text answer_text option1 option2 option3 option4 option5 option6
s
Create HTTP webpage on which Home page display “Welcome to Log in page” in
blue color and font size must be 32px, Login page shows one HTML file from
static URL having Form with detail for Username, Password, submit and reset
162 3 5
button, Gallery page reflect one Image “hello.jpg” and any other page shows
“Page Not found”.
Write all necessary files to perform task. (Image already exist in same folder)
L.J. Institute of Engineering & Technology, Ahmedabad
FSD-2 Practice Book_2024
Note: The Practice Book is for reference only, LJU Test paper may not be compulsory set from this
Sr.No unit_no question_text answer_text marks option1 option2 option3 option4 option5 option6
It allows us to set up middleware to respond to HTTP It defines a routing table that can work as per HTTP
163 4 Which of the following are the core features of the Express framework? All of the above. 1 It is used to render the HTML pages dynamically. All of the above.
Requests. Method and URL.
Where are the captured values populated regarding the route
164 4 req.params 1 req.data app.locals req.params All of the above
parameters?
Which of the following function arguments are available to Express.js
165 4 All of the above 1 req - the request object res - the response object next All of the above
Route handlers?
166 4 Which of the following is a middleware in Express.js? function(req,res,next){ } 1 function(req){ } method(req){ } function(req,res,next){ } method(req,res,next){ }
167 4 Which of the following is the correct syntax to use Express.js in Node? var app = require('express'); 1 var = require('express'); var_require('express'); var app = require('express'); None of the above.
____ functions are those that interact with the request and response
173 4 Middleware 1 Data binding Routing Middleware Forms Data connect element
objects (req, res) during the request-response cycle?
174 4 What is the purpose of the Express.js app.listen() function? To start the application server 1 To start the application server To stop the application server To restart the application server To connect to a database
175 4 What is the purpose of the req object in Express.js? To represent the HTTP request 1 To represent the HTTP request To represent the HTTP response To store session data To store user authentication data
176 4 What is the purpose of the res object in Express.js? To represent the HTTP response 1 To represent the HTTP request To represent the HTTP response To store session data To store user authentication data
_____ method is used to set content type in express JS. Consider res,
177 4 app and expr as objects of response, express alias and express res.set() 1 app.set() expr.set() res.set() app.use()
respectively.
const username=req.query.name;
Identify the correct code snippet to store passed “name” parameter to const username=req.query["name"]; res.cookie("uname",username, {expires:new
const username=req.query.name; const uername=req.query["name"]; const username=req.query.name;
178 4 cookie, which expires after closing browser and terminate by printing 1 res.cookie("uname",username,{expires:new Date(Date.now()+1000)});
res.cookie("uname",username); res.send("Done"); res.cookie("uname",username); res.send("Done"); res.cookie("uname",username); res.send("Done");
“Done”. Date(Date.now()+1000)}); res.send("Done"); res.send("Done");
Identify the valid signature of app.get() method. req,res and next are
180 4 app.get("/",function(req,res,next){}); 1 app.get("/",function(req){}); app.get("/",function(res){}); app.get("/",function(req,res){}); app.get("/",function(req,res,next){});
the objects of request, response and middleware respectively.
186 4 Which of the following is the correct syntax to use Express.js in Node? var app = require('express')(); 0.5 var_require('express')(); var = require('express')(); var app = require('express')(); var = import('express')();
187 4 Identify the method to destroy the cookie from browser. response.clearCookie("CookieName") 0.5 response.destroy("CookieName") response.delete("CookieName") response.destroyCookie("CookieName") response.clearCookie("CookieName") request.clearCookie("CookieName") request.destroy("CookieName")
Identify correct way to retrieve value of uname property using post app.post("/transfer",url,(req,res)=>{ app.post("/transfer",url,(req,res)=>{ app.post("/transfer",url,(req,res)=>{ app.post("/transfer",url,(req,res)=>{
188 4 Both (A) & (B) 0.5 Both (A) & (B) Both (C) & (D)
method. “url” is an object of URL encoding. res.send(req.body.uname)}) res.send(req.body["uname"])}) res.send(req.query.uname)}) res.send(req.query["uname"])})
to send response back to client with a rendered to send response back to client with a rendered to update database record based on data submitted in
189 4 What is the purpose of response.render() method in express.js? 0.5 to redirect client to different URL to parse incoming request bodies and extract form data to write something on browser to terminate writable stream
template template form
Identify output/error from following code. uname is a name of textfield
having content “xyz”.
190 4 <h1>xyz<h1> 1 xyz with <h1> effect Error as content inside send() is not a JSON object { uname: "xyz"} Error as application/json is not a valid MIME type Error as status code must be set in set() method <h1>xyz<h1>
response.set("content-type","application/json")
response.send(`<h1>${request.body.uname}</h1>`)
L.J. Institute of Engineering & Technology, Ahmedabad
FSD-2 Practice Book_2024
Note: The Practice Book is for reference only, LJU Test paper may not be compulsory set from this
Sr.No unit_no question_text answer_text marks option1 option2 option3 option4 option5 option6
194 4 What is the purpose of req.params object in Express.js? To store HTTP request parameters 0.5 To store HTTP request cookies To store HTTP request headers To store HTTP request body To store HTTP request parameters To handle authentication and authorization To store session data
195 4 Which module is used to parse HTTP request bodies in Express.js? body-parser 0.5 express-json-parser http-body-parser express-form-parser express-request-parser body-parser express-body-parser
Which method should be used to destroy a session and remove session
196 4 req.session.destroy() 0.5 req.session.destroy() req.session.remove() req.session.clear() req.session.delete() req.deleteID() res.set.session()
data in express-session?
How can you set a cookie with an expiration based on maxAge using res.sendCookie(name, value, {maxAge: res.setHeader('Set-Cookie', name=value;
197 4 res.cookie(name, value, {maxAge: milliseconds}) 1 res.setCookie(name, value, {maxAge: milliseconds}) res.cookie(name, value, {maxAge: milliseconds}) res.cookie(name, value, {expires: date}) res.set('Cookie', name=value; maxAge=milliseconds)
express.js? milliseconds}) maxAge=milliseconds)
198 4 How do you retrieve the value of a cookie in Express.js? Using the req.cookies object 1 Using the req.value() method Using the req.cookie() method Using the req.cookies object Using the req.body object Using req.set() object Using res.set() object
Identify the correct syntax for setting a cookie with expiry time in res.cookie('Name', 'Value', { expires: new res.cookie('Name', 'Value', { expires: new res.cookie('Name', 'Value', { maxAge:(Date.new() + req.cookie('Name', 'Value', { expires: new req.cookie('Name', ‘Value', { maxAge: Date.now() *
200 4 1 res.cookie('Value', 'Value', { maxAge: 86400000 }); res.cookie('Name', 'Value', { expires: 86400000 sec });
Express JS ? Date(Date.now() + 86400000) }); Date(Date.now() + 86400000) }); 86400000) }); Date().getTime() + 86400000 }); 86400000 });
Give output of following code on web browser:
const expr=require("express");
const app=expr();
app.get("/",(req,res)=>
{ Hello World! <h1>Hello World!
201 4 Hello world! 1 <h1> Hello from LJ</h1> Hii <h1> Hello from LJ</h1> Hello world! Nothing gets print (Blank page)
res.set("content-type","text/html"); Hello from LJ Hello from LJ</h1>
res.write("Hello world!");
res.send("<h1> Hello from LJ</h1>");
});
app.listen(5004);
Give output of following code on web browser:
const express = require('express');
const app = express();
var st = { user: 2}
202 4 app.get('/', function (req, res) { Nothing gets print (Blank page) 1 Hello Hello world! Nothing gets print (Blank page) Hello 2 2 user:2
res.write("Hello");
res.json(st.user);
});
app.listen(5004);
const expr=require("express");
const app=expr();
const student=[{name:"ABC",age:28},{name:"PQR",age:31}
,{name:"XYZ",age:20}];
app.get("/",(req,res)=>
{
res.set("content-type","text/html");
for (x=0;x<student.length;x++)
{ ABC 20 ABC 20 XYZ 20 ABC 31 XYZ 31 PQR 31 XYZ
203 4 for(j=x+1;j<student.length;j++) PQR 28 1 PQR 28 ABC 28 PQR 28 ABC 28 ABC 28 ABC
{if(student[x].age > student[j].age) XYZ 31 XYZ 31 PQR 31 XYZ 20 PQR 20 XYZ 20 PQR
{ temp=student[x].age;
student[x].age=student[j].age;
student[j].age=temp; }
}}
for(i=0;i<student.length;i++)
{ res.write(student[i].name+"\t"+student[i].age+"<br>") }
res.Send()
}); app.listen(6001);
Select correct output/error option of below code.
app.get('/cookie', function(req, res){
res.cookie('name', 'express'); //Sets name = express
//req.cookie('ID','2',{ maxAge: 2000}); It will give an error regarding clearcookies It will display json object of name, id and email in It will display json object of name and id in browser. It will display json object of name, id and email in
204 4 1 It will give an error regarding clearcookies function. It will give an error regarding req.cookie function. It will display array of name, id and email.
res.cookie('email', 'express@gmail.com'); function. browser. And Id will not be expired in 2 seconds. browser. And Id will be expired in 2 seconds.
res.clearCookies('email');
res.send(req.cookies);
});
L.J. Institute of Engineering & Technology, Ahmedabad
FSD-2 Practice Book_2024
Note: The Practice Book is for reference only, LJU Test paper may not be compulsory set from this
Sr.No unit_no question_text answer_text marks option1 option2 option3 option4 option5 option6
const cb=(req,res,next)=>
{ res.write("<p>First</p>");
next(); }
First
const cb1=(req,res,next)=> First First Second
205 4 1 <p>First</p><p>Third</p> First Second Third Second Error will be generated
{ res.write("<p>Second</p>"); Third Third Third
Third
next(); }
app.use("/test",cb);
app.get("/test",(req,res)=>
{ res.write("<p>Third</p>");
res.send(); });
What is the output of following code on request URL::
“http://localhost:3000/rollno:1000:hi” in express.
var express = require('express');
var app = express();
206 4 The name you specified is [object Object] 1 The name you specified is rollno:1000:hi The name you specified is rollno:1000 The name you specified is rollno The name you specified is [object Object] The id you specified is [null] The id you specified is hi
app.get('/:name', function(req, res){
res.send('The name you specified is ' + req.params);
});
app.listen(3000);
This function is used to interact with the request and
This function binds and waits for connections on This method accepts an object as input and returns it This method specifies what to execute when a get This method is used to transmit a limited amount of This function binds and waits for connections on the This method is used to transmit a large amount of
207 4 What does the following do, app.listen(port, [callback]])? 0.5 response objects (req, res) during the request-response
the provided host. to the requesting client. request at the specified route is made. data. provided host. data.
cycle.
Which object is used to handle data sent to the server through string or
208 4 Request 0.5 Response Request App Next Render Redirect
JSON object?
209 4 What is middleware in Express.js? A function 0.5 A language A library A database A server A function JSON Object
210 4 Which method of request.cookies attribute is used to read a cookie? get() 1 set() get() read() cp() filter() find()
Process a form using post method. Form has fields like username,
password, confirm password, gender, submit and reset buttons. After
entering all fields, If password and confirm password matches, then
212 4 form should be processed and all relevant and selected fields’ values 5
should be printed. Otherwise, by printing warning message in red
color, it should terminate. No need to write file having form
elements.
219 4 how can you create and use a middleware function in express js? 3
write an express js to link html , css and js file and show one image
220 4 3
o.jpg. And also show the description of image.
using Express js make student information form only two fileds like
221 4 name and mobile no and send data on console after submitting 5
"submit" button
L.J. Institute of Engineering & Technology, Ahmedabad
FSD-2 Practice Book_2024
Note: The Practice Book is for reference only, LJU Test paper may not be compulsory set from this
Sr.No unit_no question_text answer_text marks option1 option2 option3 option4 option5 option6
You have been assigned to develop a user feedback form for a website
using Express.js and cookies. Implement the following requirements:
Process a form with the following fields: Name, Email , Message ,
Rating (radio buttons: Bad, Average, Good, Very Good, Excellent)
When the user submits the form, store their feedback information
(name, email, message, and rating) in a cookie named "feedback" that
expires in 10 seconds. Display a confirmation message to the user after
224 4 4
successfully submitting the form & Create a link to display the
feedback details stored in the "feedback" cookie. When the user click
to the link, retrieve the feedback information from the cookie and
display it on the page also include a link on the feedback details page
to Logout. When the user clicks the link, user redirected to home page.
Make app.js file use get method in express js. No need to write html
file having form elements.
write express script to maintain session and print how many times user
visit the page. For ex., if user visit first time ,”you have visited page
225 4 3
First time” message will print. if user visit second time ,”you have
visited page second time” message will print. and so on
Write an express.js script to define 2 pages. 1st page has username and
227 4 password. Store this username to cookie on 2nd page. Cookie must 2
stay live for 1 day.
Write an express js script to link html , css and js file to show message
231 4 2
“LJ University with a difference” with font size 50px and color “blue”.
Sr.No unit_no question_text answer_text marks option1 option2 option3 option4 option5 option6
Write an express.js script to print "The Pacific Ocean is the largest and
234 4 2
deepest of the world ocean" also run on appropriate localhost.
242 5 Which middleware is commonly used in Express.js to handle file uploads? multer 0.5 body-parser multer express-fileupload connect-multiparty express-cookie fs
243 5 Which HTTP method is typically used for file uploads in web applications? POST 0.5 GET PUT POST DELETE UPLOAD Both (A)& (C)
244 5 Which event is emitted by Multer when a file upload is completed successfully? 'upload' 0.5 'upload' 'file' 'complete' 'finish'
245 5 Which HTTP method is typically used for retrieving data from a RESTful API in Express.js? GET 1 GET PUT POST DELETE
Which status code should be returned when a resource is successfully created in a RESTful
246 5 201 Created 1 201 Created 200 OK 400 Bad Request 404 Not Found
API?
247 5 What is the file extension for Pug templates in Express.js? .pug 0.5 .pug .hbs .ejs .html
to send a response back to the to send a response back to the client with a rendered to update a database record based on data submitted in a to parse incoming request bodies and extract form
248 5 What is the purpose of the "res.render" method in Express.js? 1 to redirect the client to a different URL
client with a rendered template template form data
249 5 In Express.js, how do you set up Pug as the default view engine? app.set('view engine', 'pug') 1 app.configure('views', 'pug') app.engine('pug', require('pug').__express) app.use('view engine', 'pug') app.set('view engine', 'pug')
250 5 How do you pass data to a Pug template in Express.js? res.render('template', {data: data}) 1 res.render('template', {data: data}) res.send('template', {data: data}) res.render('data', {template: template}) res.send('data', {template: template})
251 5 Which module is required to send an email in Express.js? Nodemailer 1 Nodemailer Express-mailer NodeMail Express-sendmail
Which of the following is the correct way to handle errors that occur during the email sending Using the .catch() method on the Using the .then() method on the Using the .finally() method on the nodemailer
252 5 1 Using a try-catch block Using the .catch() method on the nodemailer promise
process in Express.js? nodemailer promise nodemailer promise promise
To handle HTTP requests
To render a view template in the To handle server-side rendering
253 5 What is the purpose of the Express.js res.redirect() method? 1 To send data back to the client To render a view template in the application To redirect the client to a different URL To handle errors that occur in the application based on the URL and
application in the application
HTTP method
const
Identify correct statement/statements to set constraint of file size up to 1 KB during file const maxsize=1*1024; const maxsize=1*1024;
254 5 1 const maxsize = 1*1024; limits:maxsize const maxsize=1*1024; limits:{fileSize:maxsize} maxsize=1*1024*1024;limits:{fileSize:m const maxsize=1*1024*1024; limits:maxsize; Both (C) & (E)
upload.consider JSON code inside multer callback. limits:{fileSize:maxsize} limits=maxsize;
axsize}
255 5 How do you write comments in Pug? //pug 0.5 \\pug **pug /*pug //pug <!—pug--> $$pug
var mailOption=
var mailOption= var mailOption= var mailOption= var mailOption=
{
{ { { {
from:"abc@gmail.com",
from:"abc@gmail.com", from:"abc@gmail.com", from:"abc@gmail.com", from:"abc@gmail.com",
to:"xyz@gmail.com",
to:"xyz@gmail.com", to:"xyz@gmail.com", to:"xyz@gmail.com", to:"xyz@gmail.com",
256 5 What is the correct syntax to send HTML formatted text in your email? 1 subject:"test mail",
subject:"test mail", subject:"test mail", subject:"test mail", subject:"test mail",
content_type:"text/html",
html:"<h1>its easy</h1>" text:"<h1>its easy</h1>" html:"<h1>its easy</h1>" text:"its easy"
content:"<h1>its easy</h1>"
} } } }
}
<form action="upload"
<form action="upload" <form action="upload"
<form action="upload" method="get" <form action="upload" method="post" method="post"
257 5 Identify correct specification of <form> tag to upload a file. method="post" 0.5 <form action="upload"> <form action="upload" method="post"> method="post"
enctype="multipart/form-data"> encryptiontype="multipart/form-data"> enctype="multipart/form-
enctype="multipart/form-data"> enctype="text/html">
data">
258 5 _____ method is used to prepare storage of a file after uploading multer.diskStorage() 0.5 multer.disk() multer.diskStorage() multer.keepStorage() path.keepStorage() multer.diskAvailable() multer.storage()
264 5 Which attribute is used to filter specific file in choose files dialog box? accept 0.5 type method filter accept name value
L.J. Institute of Engineering & Technology, Ahmedabad
FSD-2 Practice Book_2024
Note: The Practice Book is for reference only, LJU Test paper may not be compulsory set from this
unit_
Sr.No question_text answer_text marks option1 option2 option3 option4 option5 option6
no
265 5 Which method is used to set HTTP response headers in Express.js? res.set() 0.5 res.head() res.send() res.end() app.set() res.set() res.header()
266 5 Which module is used to create a RESTful API in Express.js? express.Router() 1 expressREST restfulExpress express.Router() expressAPI express.REST() app.Router()
Which of the following is the correct syntax to upload specific size file for defined variable as:
267 5 limits:{fileSize:maxSize} 1 limits:{size:maxSize} limit:maxSize limit:{file:maxSize} size:maxSize limits:{fileSize:maxSize} limits:{maxSize:maxSize}
Var maxSize=1*1024*1024
268 5 Which of the following is an example of a route parameter in Express.js? /users/:id 1 /users /users/:id /users/send /users/delete /users/set:id /users/res.set(id)
What will be the output of the below pug code?
//-Buffered
// ABC
Buffered will be seen as a
p ABC ABC XYZ Only Buffered will be display in browser ABC
269 5 1 Nothing will be displayed comment in html source code. XYZ
p XYZ XYZ ABC but not in html source code. XYZ
And only ABC will be displayed.
// XYZ
p ABC
p XYZ
270 5 What is Pug? A template engine for Node.js 1 A programming language A template engine for Node.js A database management system A web server framework A scripting language framework
Write an expressJS code in which RESTapi is created for json object named Places I love which
contains name,country,state,city and rating out of 10(no decimal points) is given.upon passing
271 4 5
ratings on the browser it should display the places having that rating.i.e. on
localhost:30001/a/10 should display all the places having 10 ratings.
write a code to create a link named “Contact Us” using a Pug template engine inside Express
code. When you click on “Contact Us” it will redirect to the next page “/contact” and display
272 4 3
the message “welcome to Contact us page”.
277 5 Write a code to implement file uploading and downloading with Express ? 5
278 5 Write express js code to pass data from my Express.js application to a Pug template? 5
279 5 How to implement search and filtering in a REST API with Express.js ? 5
282 5 Write a code to upload file and access uploaded file in express js. 3
Write express js script to load student form using pug file which contains following fields
Name(text) Email(email) Course(radio : CE, IT, CSE) Once form submitted then data must be
283 5 4
displayed on ‘/data’ page using pug file. Means data should be submitted from express
application to PUG file
Write an express js script that allows only image type file to be uploaded using the multer
284 5 middleware and saves the file to the specific directory called “IMAGES”. If file other than 4
image has been uploaded then it will give an error message that “Upload only image file”.
285 5 Write an express JS script to upload any type of file of size up to 50KB only. 3
write a code to create a link named “About Us” using a Pug template engine inside Express
286 5 code.when you click on “About Us” it will redirect to the next page “/about” and display the 4
message “welcome to About us page”.
Write an express js script to configure the multer middleware. Perform following tasks.
1) Create a pug file named "file.pug". This file contains heading(h3) "Upload your CV" in red
color. And, a form with input type file(to browse and select file) and submit(to upload the file).
2) Create a js file named "file.js" and link this js and pug file to browse pug file on "/home"
page.
289 5 5
3) After uploading a file display message on "/upload" page "(file original name) has been
uploaded".
4) Save uploaded files to specific directory named "upload". And in this folder file must be
stored in format of "lju-file.pdf" where "lju" is the field name.
Write express js script to upload file with size limit of 1 MB to a specific directory named
290 5 5
“Data” on the server.
Write an express js script to configure the multer middleware. Perform following tasks.
1) Create a html form file named "form.html" in public folder. This file contain centrally
oriented heading(h3) "Upload your File" in red color with background-color aqua. Along with
choose file option(to browse and select file) and submit button(to upload the file). (Must use
external css having name “effect.css” in public folder)
291 5 5
2) Create a js file to show result after uploading any type of file, message should be displayed
on "/upload" page "(file original name) has been uploaded".(Css effect must include while
running js code)
3) Save uploaded files to specific directory named "File". And in this folder file must be stored
in format of "data-file.pdf" where "data" is the field name.
Write ExpressJS script to load following table using pug file on localhost.
292 5 3