0
0
Node.jsframework~10 mins

os module for system information in Node.js - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the os module in Node.js.

Node.js
const os = require([1]);
Drag options to blanks, or click blank then click option'
A'fs'
B'http'
C'os'
D'path'
Attempts:
3 left
💡 Hint
Common Mistakes
Using other module names like 'fs' or 'http' instead of 'os'.
Forgetting to put quotes around the module name.
2fill in blank
medium

Complete the code to get the system's hostname using the os module.

Node.js
const hostname = os.[1]();
Drag options to blanks, or click blank then click option'
Ahostname
Bplatform
Ctype
Darch
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.platform() which returns the OS platform, not hostname.
Using os.type() which returns the OS name.
3fill in blank
hard

Fix the error in the code to get the total system memory.

Node.js
const totalMem = os.[1]();
Drag options to blanks, or click blank then click option'
Atotalmem
Bmemory
Cfreemem
DgetTotalMem
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.freemem() which returns free memory, not total.
Using non-existent methods like os.memory() or os.getTotalMem().
4fill in blank
hard

Fill both blanks to create an object with OS type and CPU architecture.

Node.js
const systemInfo = { type: os.[1](), arch: os.[2]() };
Drag options to blanks, or click blank then click option'
Atype
Bplatform
Carch
Dhostname
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up os.platform() with os.type().
Using os.hostname() instead of os.arch() for CPU info.
5fill in blank
hard

Fill all three blanks to create a summary string with platform, uptime, and user info.

Node.js
const summary = `Platform: ${os.[1]()}, Uptime: ${os.[2]()} seconds, User: ${os.userInfo().[3]`;
Drag options to blanks, or click blank then click option'
Aplatform
Buptime
Cusername
Dhostname
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.type() instead of os.platform() for platform.
Using os.userInfo().name instead of username property.
Confusing uptime with freemem or totalmem.