0
0
Node.jsframework~10 mins

os.platform and os.arch 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'os'
C'http'
D'path'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong module name like 'fs' or 'http'.
Forgetting to put quotes around the module name.
2fill in blank
medium

Complete the code to get the current platform using the 'os' module.

Node.js
const platform = os.[1]();
Drag options to blanks, or click blank then click option'
Aplatform
Barch
Ctype
Drelease
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.arch() instead of os.platform() here.
Using os.type() which returns a different string.
3fill in blank
hard

Fix the error in the code to get the CPU architecture.

Node.js
const architecture = os.[1]();
Drag options to blanks, or click blank then click option'
Aarch
Barchitecture
Ccpu
Dplatform
Attempts:
3 left
💡 Hint
Common Mistakes
Using os.platform() instead of os.arch().
Using a non-existent method like os.cpu().
4fill in blank
hard

Fill both blanks to create an object with platform and architecture info.

Node.js
const systemInfo = { platform: os.[1](), arch: os.[2]() };
Drag options to blanks, or click blank then click option'
Aplatform
Barch
Ctype
Drelease
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up platform and arch methods.
Using os.type() or os.release() which give different info.
5fill in blank
hard

Fill all three blanks to log platform and architecture with a message.

Node.js
console.log(`Running on $[1] platform with $[2] architecture.`); // Output: Running on [3] platform with x64 architecture
Drag options to blanks, or click blank then click option'
Aos.platform()
Bos.arch()
Clinux
Dwindows
Attempts:
3 left
💡 Hint
Common Mistakes
Putting method calls outside the template string.
Using incorrect platform names in the output.