2-space or 4-space indent (JavaScript)?
Unanimous. Anyone disagreeing with this in 2026 needs to log off.
The exact prompts I used (3 variants)
Each model got each prompt 20 times (2 temperatures × 10 runs). The prompts deliberately don't mention the contested choice — they ask for a normal coding task and we measure what the model actually does.
-
Write a JavaScript function that groups an array of objects by a given key. -
Write a JavaScript function that converts a snake_case string to camelCase. -
Write a JavaScript function that retries a callback up to N times if it throws.
Who said what
The pundit panel.
I showed each model the full vote tally, then asked them to defend their choice and dunk on whoever disagreed. Receipts attached.
“Four AI models, zero dissent: if you're using four-space indentation in JavaScript, you're writing Java in the wrong language.”
“If you indent JavaScript with 4 spaces, congratulations on turning every callback pyramid into a rightward death march; 2 spaces wins because JS nests constantly and readability matters.”
“Four-space JavaScript indenters are just a readability tax dodging discipline, because two spaces keep nesting tight, scan faster, and match the language’s actual style consensus.”
“Four-space indents are for developers who love wasting horizontal space to make their own deeply nested logic completely unreadable.”
Show me the actual code (240 samples)
Claude Sonnet 4.6 — 60 samples click to expand
Write a JavaScript function that groups an array of objects by a given key.
## Group By Function
Here's a clean, reusable JavaScript function that groups an array of objects by a specified key:
```javascript
/**
* Groups an array of objects by a given key.
* @param {Object[]} array - The array of objects to group.
* @param {string|Function} key - The key to group by, or a function that returns the group key.
* @returns {Object} An object where each property is a group of items.
*/
function groupBy(array, key) {
if (!Array.isArray(array)) {
throw new TypeError("First argument must be an array");
}
return array.reduce((result, item) => {
const groupKey = typeof key === "function" ? key(item) : item[key];
if (groupKey === undefined || groupKey === null) {
return result; // Skip items with no valid key
}
if (!result[groupKey])
… Write a JavaScript function that groups an array of objects by a given key.
## Group By Function
Here's a clean, reusable JavaScript function that groups an array of objects by a specified key:
```javascript
/**
* Groups an array of objects by a given key.
* @param {Object[]} array - The array of objects to group.
* @param {string|Function} key - The key to group by, or a function that returns the group key.
* @returns {Object} An object where keys are group names and values are arrays of objects.
*/
function groupBy(array, key) {
if (!Array.isArray(array)) {
throw new TypeError("First argument must be an array");
}
return array.reduce((result, item) => {
const groupKey = typeof key === "function" ? key(item) : item[key];
if (groupKey === undefined) {
console.warn(`Key "${key}" not found in item:`, item);
}
const groupName
… Write a JavaScript function that groups an array of objects by a given key.
## Group By Function
Here's a clean, reusable JavaScript function that groups an array of objects by a specified key:
```javascript
/**
* Groups an array of objects by a given key.
* @param {Object[]} array - The array of objects to group.
* @param {string|Function} key - The key to group by, or a function that returns the group key.
* @returns {Object} An object where keys are group names and values are arrays of objects.
*/
function groupBy(array, key) {
if (!Array.isArray(array)) {
throw new TypeError("First argument must be an array");
}
return array.reduce((result, item) => {
const groupKey = typeof key === "function" ? key(item) : item[key];
if (groupKey === undefined) {
console.warn(`Key "${key}" not found in item:`, item);
}
const groupName
… …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
GPT-5.4 — 60 samples click to expand
Write a JavaScript function that groups an array of objects by a given key.
```javascript
function groupBy(array, key) {
return array.reduce((result, item) => {
const group = item[key];
if (!result[group]) {
result[group] = [];
}
result[group].push(item);
return result;
}, {});
}
```
Example:
```javascript
const data = [
{ name: "Alice", role: "admin" },
{ name: "Bob", role: "user" },
{ name: "Charlie", role: "admin" }
];
const grouped = groupBy(data, "role");
console.log(grouped);
```
Output:
```javascript
{
admin: [
{ name: "Alice", role: "admin" },
{ name: "Charlie", role: "admin" }
],
user: [
{ name: "Bob", role: "user" }
]
}
```
If you want, I can also show:
- a version using `Map`
- a one-liner version
- a version that supports nested keys like `"user.role"` Write a JavaScript function that groups an array of objects by a given key.
```javascript
function groupBy(array, key) {
return array.reduce((result, item) => {
const group = item[key];
if (!result[group]) {
result[group] = [];
}
result[group].push(item);
return result;
}, {});
}
```
Example usage:
```javascript
const data = [
{ name: "Alice", role: "admin" },
{ name: "Bob", role: "user" },
{ name: "Charlie", role: "admin" }
];
const grouped = groupBy(data, "role");
console.log(grouped);
```
Output:
```javascript
{
admin: [
{ name: "Alice", role: "admin" },
{ name: "Charlie", role: "admin" }
],
user: [
{ name: "Bob", role: "user" }
]
}
```
If you want, I can also show a version using `Map` or one that accepts a callback instead of just a key. Write a JavaScript function that groups an array of objects by a given key.
```javascript
function groupBy(array, key) {
return array.reduce((result, item) => {
const group = item[key];
if (!result[group]) {
result[group] = [];
}
result[group].push(item);
return result;
}, {});
}
```
Example:
```javascript
const data = [
{ name: "Alice", role: "admin" },
{ name: "Bob", role: "user" },
{ name: "Charlie", role: "admin" }
];
console.log(groupBy(data, "role"));
```
Output:
```javascript
{
admin: [
{ name: "Alice", role: "admin" },
{ name: "Charlie", role: "admin" }
],
user: [
{ name: "Bob", role: "user" }
]
}
```
If you want, I can also show:
- a version using `Map`
- a one-liner version
- a TypeScript version …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
GPT-5.4 mini — 60 samples click to expand
Write a JavaScript function that groups an array of objects by a given key.
```js
function groupBy(array, key) {
return array.reduce((groups, item) => {
const groupKey = item[key];
if (!groups[groupKey]) {
groups[groupKey] = [];
}
groups[groupKey].push(item);
return groups;
}, {});
}
```
### Example
```js
const users = [
{ name: "Alice", role: "admin" },
{ name: "Bob", role: "user" },
{ name: "Carol", role: "admin" }
];
const grouped = groupBy(users, "role");
console.log(grouped);
```
### Output
```js
{
admin: [
{ name: "Alice", role: "admin" },
{ name: "Carol", role: "admin" }
],
user: [
{ name: "Bob", role: "user" }
]
}
```
If you want, I can also show a version using `Map` or one that supports nested keys like `"address.city"`. Write a JavaScript function that groups an array of objects by a given key.
Here’s a simple JavaScript function to group an array of objects by a given key:
```javascript
function groupBy(array, key) {
return array.reduce((result, item) => {
const group = item[key];
if (!result[group]) {
result[group] = [];
}
result[group].push(item);
return result;
}, {});
}
```
### Example usage:
```javascript
const people = [
{ name: "Alice", age: 25, city: "NY" },
{ name: "Bob", age: 30, city: "LA" },
{ name: "Charlie", age: 25, city: "NY" }
];
const groupedByAge = groupBy(people, "age");
console.log(groupedByAge);
```
### Output:
```javascript
{
25: [
{ name: "Alice", age: 25, city: "NY" },
{ name: "Charlie", age: 25, city: "NY" }
],
30: [
{ name: "Bob", age: 30, city: "LA" }
]
}
```
If you want, I can a
… Write a JavaScript function that groups an array of objects by a given key.
Here’s a simple JavaScript function to group an array of objects by a given key:
```javascript
function groupBy(array, key) {
return array.reduce((result, item) => {
const groupKey = item[key];
if (!result[groupKey]) {
result[groupKey] = [];
}
result[groupKey].push(item);
return result;
}, {});
}
```
### Example usage
```javascript
const people = [
{ name: "Alice", department: "Engineering" },
{ name: "Bob", department: "Sales" },
{ name: "Charlie", department: "Engineering" },
{ name: "Dana", department: "Marketing" }
];
const grouped = groupBy(people, "department");
console.log(grouped);
```
### Output
```javascript
{
Engineering: [
{ name: "Alice", department: "Engineering" },
{ name: "Charlie", department: "Engineering" }
],
… …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
Gemini 2.5 Pro — 60 samples click to expand
Write a JavaScript function that groups an array of objects by a given key.
Of course! Here is a JavaScript function that groups an array of objects by a given key, along with explanations and examples.
The most idiomatic and concise way to achieve this in modern JavaScript is by using the `Array.prototype.reduce()` method.
### The Solution (using `reduce`)
This function iterates over the array and builds up a new object (the "accumulator"), where each key is a unique value from the specified grouping key.
```javascript
/**
* Groups an array of objects by a specified key.
*
* @param {Array<Object>} array The array of objects to group.
* @param {string} key The key to group the objects by.
* @returns {Object} An object where keys are the group names and values are arrays of objects belonging to that group.
*/
const groupBy = (array, key) => {
// Return
… Write a JavaScript function that groups an array of objects by a given key.
Of course! Here are a few ways to write a JavaScript function that groups an array of objects by a given key, along with explanations for each approach.
The most common and idiomatic way to do this in modern JavaScript is using the `Array.prototype.reduce()` method.
### 1. The Modern Approach (using `Array.prototype.reduce`)
This method is concise and powerful. It iterates over an array and builds up a single value (in this case, an object containing our groups).
```javascript
/**
* Groups an array of objects by a specified key.
*
* @param {Array<Object>} array The array of objects to group.
* @param {string} key The key to group the objects by.
* @returns {Object} An object where keys are the group names and values are arrays of objects.
*/
const groupBy = (array, key) => {
//
… Write a JavaScript function that groups an array of objects by a given key.
Of course! Here are a few ways to write a JavaScript function that groups an array of objects by a given key, along with explanations for each approach.
The most common and idiomatic way to do this in modern JavaScript is using the `Array.prototype.reduce()` method.
### 1. The Modern Approach (using `Array.prototype.reduce`)
This method is concise and powerful. It iterates over an array and builds up a single value (in this case, an object containing our groups).
```javascript
/**
* Groups an array of objects by a specified key.
*
* @param {Array<Object>} array The array of objects to group.
* @param {string} key The key to group the objects by.
* @returns {Object} An object where keys are the group names and values are arrays of objects.
*/
const groupBy = (array, key) => {
//
… …and 57 more samples (across 3 prompt variants × 2 temperatures × 10 runs). Full data in the result JSON on GitHub.
How I did this (the actual nerd shit)
For each of 4 models I ran 3 prompt variants at two temperatures (0.0 and 0.7), 10 runs each — 240 code samples total, cost $3.42.
Each output got fed through a fight-specific regex classifier.
For indent-width-js the classifier looks for the specific signal in the output
(see the source — there's one function per fight, ~30 lines each).
When the signal is ambiguous, the classifier returns 'unknown' rather than guess.
Each model's vote = its modal classification across 60 runs. Confidence = Wilson 95% CI. Verdict = majority across models (ties reported as ties). Disagreement Index = normalized Shannon entropy of the vote distribution (0 = unanimous, 1 = maximum chaos). Leaderboard sorts by this.
The pundit quotes come from a follow-up call after the votes are in — each model gets the full tally and a per-model judgy prompt. I never edit the quotes.
Full walkthrough: the methodology page. Source: GitHub.
Open a PR with a new fight. I'll run it across all four models, write up the verdict, and add your name to the byline.
Submit via PR →