0
0
Node.jsframework~10 mins

process.exit and exit codes 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 exit the Node.js process with a success code.

Node.js
process.[1](0);
Drag options to blanks, or click blank then click option'
Aquit
Bexit
Cstop
Dend
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods like quit or stop which do not exist on process.
Not passing an exit code.
2fill in blank
medium

Complete the code to exit the process with an error code 1.

Node.js
process.exit([1]);
Drag options to blanks, or click blank then click option'
A1
B255
C2
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 which means success.
Using exit codes outside the valid range 0-255.
3fill in blank
hard

Fix the error in the code to properly exit the process with code 2.

Node.js
process.exit = [1];
Drag options to blanks, or click blank then click option'
A() => process.exit(2)
Bexit(2)
C2
Dprocess.exit(2)
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning a number directly to process.exit.
Calling process.exit inside assignment without a function wrapper.
4fill in blank
hard

Fill both blanks to exit with code 3 after logging an error message.

Node.js
console.error('Error occurred');
process.[1]([2]);
Drag options to blanks, or click blank then click option'
Aexit
B1
C3
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Using invalid method names like stop.
Passing wrong exit codes like 1 instead of 3.
5fill in blank
hard

Fill all three blanks to exit with code 4 only if an error variable is true.

Node.js
if ([1]) {
  console.log('Exiting due to error');
  process.[2]([3]);
}
Drag options to blanks, or click blank then click option'
Aerror
Bexit
C4
Dfail
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined variables in the condition.
Using invalid method names instead of exit.
Passing wrong exit codes.