REPL — Node.js Technical Interview Questions & Answers

REPL

REPL

  • REPL is the Node prompt: type node with no file. You try 2+2 and see 4. .exit to leave. Great for testing a one-liner. Not how you ship an API.
  • Trap: thinking REPL is the production server.

Technical Interview Tip: Type node, try 2+2, .exit.

Code Examples for REPL

REPL — working example

// REPL
const users = [
  { id: 1, name: "Asha" },
  { id: 2, name: "Ravi" },
];

function findUser(id) {
  return users.find((u) => u.id === id) ?? null;
}

console.log(findUser(2));
console.log(users.map((u) => u.name));

REPL: find user 2, then list names. Say both prints.

How to Explain REPL to an Interviewer

How do you open the REPL?

Run node with no filename .exit to quit