Creative Run: May 28, 2026

Roast My Code

A personality test that still has to spot the real async bug.

Prompt

temp 0.7 max 2048 tokens first response only
Roast this JavaScript code. Be genuinely funny, but technically accurate — point out the real bugs and bad practices while making me laugh. Keep it under 150 words.

function getData(id){
  var data = null;
  fetch('/api/user/' + id).then(r => r.json()).then(d => { data = d });
  return data;
}

Pick your favorite

Model names stay hidden until you vote or reveal.

Model

Hidden


			This function is the JavaScript equivalent of ordering pizza, immediately checking the empty doorstep, and declaring dinner `null`.

Real crimes:

- `fetch` is async, but you return `data` synchronously, so this always returns `null` unless the universe glitches.
- Mutating outer `var data` inside `.then()` is callback archaeology.
- `var`? What is this, a museum exhibit?
- No `catch`, so errors vanish like your hopes of getting user data.
- No `r.ok` check, so a 500 response gets lovingly parsed as if everything’s fine.
- `id` is jammed into a URL raw. `encodeURIComponent(id)` exists; please use it before someone passes `"../../chaos"`.

Better:

```js
async function getData(id) {
  const r = await fetch(`/api/user/${encodeURIComponent(id)}`);
  if (!r.ok) throw new Error(`HTTP ${r.status}`);
  return r.json();
}
```

Now it actually gets data. Revolutionary.
		

Model

Hidden


			Ah yes, the classic "Schrödinger's Data" pattern. You've written a function that confidently promises to return user data, then sprints past the fetch like it's a stranger at a party, and hands back `null` with the smug confidence of someone who's never heard the word "asynchronous."

That `data = d` assignment? It happens. Eventually. Probably while your UI is already on fire and the user has rage-quit. By the time the Promise resolves, `data` has been garbage collected, your component has unmounted, and three new JavaScript frameworks have been released.

Also, `var`? In *this* economy? It's 2024, we use `const` now, like adults who've made peace with their lexical scope.

Bonus crimes: no error handling (because what could go wrong with a network request?), no input validation (enjoy `/api/user/undefined`), and string concatenation for URLs like it's a PHP tutorial from 2007.

Return the Promise, you coward.
		

Model

Hidden


			Congratulations, you just wrote the world’s most expensive way to type `return null;`. 

Because `fetch` is asynchronous, your code fires off the network request and immediately sprints to `return data` before the server even blinks. That `.then()` block is basically a post-it note left on an empty desk. 

Also, `var`? What year is this, 2013? Put down the jQuery and use `let` or `const`. 

While we’re at it, string concatenation for URLs (`+ id`) is a crime against template literals. And I see you omitted a `.catch()` block—because why handle network errors when you can just let your application die in silent agony, right? 

Throw this away, Google `async/await`, and apologize to the JavaScript event loop.
		

Model

Hidden


			The classic "async-pretending-to-be-sync" anti-pattern! 

Your `getData` function is like a teenager promising to clean their room, but actually just staring at it. It returns `null` immediately, while the `fetch` call is still out fetching. The `data` variable is only updated in the callback, but by then, the function has already returned.

The fix? Use `async/await` or return the promise. Don't make promises you can't keep (pun intended). This code is like a broken horoscope: "Data will be returned... eventually... maybe... don't hold your breath." 

Try this instead: `async function getData(id) { return await fetch('/api/user/' + id).then(r => r.json()); }` or `function getData(id) { return fetch('/api/user/' + id).then(r => r.json()); }`
		

Model

Hidden


			This function is the JavaScript equivalent of calling someone and immediately hanging up before they answer. It returns `null` every time because `fetch` is async, so you're handing back an empty plate while the actual data shows up fashionably late to a party that's already ended.

Also, zero error handling means if that API 404s or the network dies, `data` stays `null` and your code just shrugs like nothing happened. You've successfully written a function that lies to callers synchronously while betraying them asynchronously.
		

Model

Hidden


			This function is the JavaScript equivalent of ordering pizza and returning an empty box. It proudly fetches data, then immediately returns `null` because `fetch` is asynchronous. The promise is left to resolve in the void, like a sad, forgotten background task.

You've also used `var` like it's 2010 and concatenated strings like a script kiddie. Template literals exist. Also, no error handling? Bold. This function will fail silently, leaving you to debug with console.log and tears.

In short, it’s a race condition where `null` always wins. Use `async/await` or actually return the promise, you heathen.
		

Get the next showdown

One useful model comparison, written for builders, when a new Arena entry ships.