Skip to content

predict · generated

A model wrote this helper. Say what it returns and what it changed on the way, before you run it.

Answer before anything runs. Then the machine runs it, and you can step through what it did.

const BASE = { role: "viewer", scopes: [] };

function grant(user, scope) {
  const next = { ...BASE, ...user };
  next.scopes.push(scope);
  return next;
}

const alice = grant({ name: "alice" }, "read");
const bob = grant({ name: "bob" }, "write");
const aliceScopes = alice.scopes.length;
const baseScopes = BASE.scopes.length;
What does `aliceScopes` hold when the program has finished?
What does `baseScopes` hold when the program has finished?
Put the names that point at the same object into the same group
name12
alice.scopes
bob.scopes
BASE.scopes