Compare multiple items side-by-side using real API data
Select what you want to compare: Pokemon, Star Wars characters, weather, or countries
Use the input field to add items, or try the quick start examples and random buttons
View side-by-side comparisons, statistics, and use battle mode for head-to-head matchups
Save your comparison data and share your findings with others
Detailed information about countries, including demographics and geography
Learn Moreasync function getMultipleItems(itemNames) {
try {
console.log(`π₯ Fetching ${itemNames.length} items simultaneously...`);
// Create array of fetch promises
const fetchPromises = itemNames.map(name =>
fetch(`${API_BASE}/${name.toLowerCase()}`)
.then(response => {
if (!response.ok) throw new Error(`${name} not found`);
return response.json();
})
);
// Wait for all promises to complete
const itemData = await Promise.all(fetchPromises);
console.log('β
All items loaded successfully!');
return itemData;
} catch (error) {
console.error('β Failed to fetch items:', error);
throw error;
}
}
function analyzeComparison(items) {
const stats = {
count: items.length,
categories: {}
};
// Find strongest in each category
if (comparisonType === 'pokemon') {
const attacks = items.map(p => getStatValue(p, 'attack'));
const defenses = items.map(p => getStatValue(p, 'defense'));
stats.strongest = {
attacker: items[attacks.indexOf(Math.max(...attacks))],
defender: items[defenses.indexOf(Math.max(...defenses))]
};
}
// Calculate averages
stats.averages = calculateAverages(items);
return stats;
}
function generateInsights(stats) {
const insights = [];
if (stats.strongest) {
insights.push(`πͺ Strongest attacker: ${stats.strongest.attacker.name}`);
insights.push(`π‘οΈ Best defender: ${stats.strongest.defender.name}`);
}
return insights;
}
function renderComparisonGrid(items) {
const grid = document.getElementById('comparisonGrid');
// Create responsive grid
grid.style.gridTemplateColumns =
`repeat(auto-fit, minmax(300px, 1fr))`;
grid.innerHTML = items.map((item, index) => `
<div class="comparison-card" data-index="${index}">
<div class="card-header">
<h3>${item.name}</h3>
<button onclick="removeItem(${index})" class="remove-btn">Γ</button>
</div>
<div class="card-content">
${generateCardContent(item)}
</div>
<div class="card-actions">
<button onclick="selectForBattle(${index})">Select for Battle</button>
</div>
</div>
`).join('');
// Add animation
animateCards();
}