Skip to content
Foxipa
Code Completion 8 Challenges

Complete the JavaScript Architecture Code

Practice focused APIs, dependency injection, composition roots, adapters, state ownership, and lifecycle boundaries.

Intermediate ~8 min read

Challenge 1

Expose formatName as the public API.

javascript Your answer
function formatName(value) { return value.trim(); }

Press Ctrl⌘Enter to check your answer

Challenge 2

Accept a replaceable logger dependency.

javascript Your answer
export function run(logger) {
  
  logger("started");
}

Press Ctrl⌘Enter to check your answer

Challenge 3

Create the concrete repository before composing the feature.

javascript Your answer
const repository = ;
const feature = createFeature({ repository });

Press Ctrl⌘Enter to check your answer

Challenge 4

Create an adapter object with save().

javascript Your answer
return { (value) { storage.setItem("value", JSON.stringify(value)); } };

Press Ctrl⌘Enter to check your answer

Challenge 5

Return the result of the pure calculation.

javascript Your answer
export function total(items) {
  return ;
}

Press Ctrl⌘Enter to check your answer

Challenge 6

Expose stop as the lifecycle cleanup operation.

javascript Your answer
return { start,  };

Press Ctrl⌘Enter to check your answer

Challenge 7

Keep the mutable count private to the module.

javascript Your answer
let  = 0;
export function increment() { count += 1; }

Press Ctrl⌘Enter to check your answer

Challenge 8

Pass the clock into the function.

javascript Your answer
export function expiresAt(duration) { return now() + duration; }

Press Ctrl⌘Enter to check your answer