WorksheetsModule 08: Introduction and Recall
Total questions: 10
Worksheet time: 5mins
Which layer primarily handles data, logic, and security in a web application?
Browser rendering pipeline
Back-end engine and services
Client-side styling tools
Front-end interface for users
What is the main role of Express.js when used with Node.js?
Building server-side routes
Serving static images
Animating buttons on pages
Designing page layouts
Which statement best describes middleware in an Express server shown in the project?
Files that automatically configure the operating system
Modules that replace the Node.js runtime engine
Scripts that only execute after the server shuts down
Functions that run before main route handlers
In the server setup, what is the primary purpose of app.use(express.static('public'))?
Return JSON for the /api/logs route
Serve files from the public directory
Log each request path and time
Start the server on a given port
A visitor opens index.html and then requests /api/logs. Which route returns the stored log array in JSON?
app.get('/api/logs', (req, res) => res.json(visitorLog))
app.use((req, res) => res.send(visitorLog))
app.listen(PORT, () => res.json(visitorLog))
app.post('/api/logs', (req, res) => res.json([]))
In an Express-based Visitor Logger, why is relying only on in-memory storage unsuitable for real-world apps?
It blocks building APIs for user login
Data is lost on server restart or refresh
It prevents middleware from validating inputs
It slows down requests under light traffic
Which command installs the required Node.js packages for an Express server using SQLite and body parsing?
npm install express sqlite3 body-parser
npm add express sqlite3 body-parser quickly
node install express sqlite3 body-parser
npm start express sqlite3 body-parser
In the server code, what is the purpose of db.run('INSERT INTO visitors ... VALUES (?, ?, ?, ?, ?)', [lastname, firstname, address, email, phone])?
Deletes a visitor record matching the array values
Creates the visitors table with five text columns
Updates all visitor rows with new values
Adds a new visitor record using parameter placeholders
Which input type enforces an email format for the visitor’s email field?
type="url" for email
type="number" for email
type="email" for email
type="text" for email
Which DOM method attaches a click handler to the 'Display Records' button?
querySelectorAll for clicks
onclick attribute on table
setTimeout on button
addEventListener on element
