The Borda Count method is a ranked-choice voting system used to elect a single winner from multiple candidates. Developed by Jean-Charles de Borda in the 1770s, it aims to select a candidate who is not only acceptable to the majority but also has broad support across different voter preferences. It's often seen as a compromise between simple plurality voting and more complex consensus-based methods.
How it Works:
Voters rank candidates in order of preference. For example, if there are 4 candidates (A, B, C, D), a voter might rank them as B > A > D > C.
Points are assigned to each candidate based on their rank. If there are N candidates, the top-ranked candidate receives N-1 points, the second-ranked candidate receives N-2 points, and so on, down to the last-ranked candidate who receives 0 points.
Each voter's ballot is tallied, and the points for each candidate are summed up across all ballots.
The candidate with the highest total Borda score is declared the winner.
Example Calculation:
Let's say there are 3 candidates (A, B, C) and 3 voters.
In this specific scenario, there is a tie. Tie-breaking rules would need to be applied. The Borda count method often avoids the "spoiler effect" common in plurality voting and can lead to more broadly acceptable winners.
Use Cases:
Political elections where consensus is valued.
Internal organizational elections (e.g., club officer selection).
Ranking competitions or awards where overall preference matters.
Determining preferences in situations with multiple options and subjective rankings.
var candidateCount = 2; // Start with two candidates
function addCandidate() {
candidateCount++;
var newCandidateDiv = document.createElement('div');
newCandidateDiv.className = 'candidate-input-group';
newCandidateDiv.innerHTML = `
`;
document.getElementById('candidates-area').appendChild(newCandidateDiv);
}
function calculateBorda() {
var candidateData = [];
var totalVoters = 0;
var errorMessage = "";
var resultDisplay = document.getElementById('result-display');
var errorMessageDisplay = document.getElementById('error-message');
resultDisplay.style.display = 'none';
errorMessageDisplay.innerText = "";
// First, determine the total number of voters from the first candidate's rankings
var firstCandidateRanksInput = document.getElementById('candidateRanks1');
if (firstCandidateRanksInput && firstCandidateRanksInput.value.trim() !== "") {
var firstRanks = firstCandidateRanksInput.value.split(',').map(function(rank) { return parseInt(rank.trim(), 10); });
if (!isNaN(firstRanks[0])) { // Check if the first parsed value is a number
totalVoters = firstRanks.length;
}
} else {
errorMessage += "Please enter rankings for at least one candidate.";
}
for (var i = 1; i 0) {
errorMessage += `Number of rankings for ${name} (${ranks.length}) does not match the number of voters (${totalVoters}).`;
// Don't 'continue' here, var it attempt calculation but warn the user
}
} else {
errorMessage += `Rankings for ${name} cannot be empty.`;
continue; // Skip to next candidate if rankings are missing
}
candidateData.push({ name: name, ranks: ranks });
}
if (errorMessage !== "") {
errorMessageDisplay.innerHTML = errorMessage;
return;
}
if (candidateData.length === 0) {
errorMessageDisplay.innerText = "No valid candidate data entered.";
return;
}
// Now calculate Borda scores
var numCandidates = candidateData.length;
var bordaScores = {};
var candidateNames = candidateData.map(function(c) {
bordaScores[c.name] = 0; // Initialize score
return c.name;
});
// Validate the ranking numbers for each candidate against the maximum possible rank
var maxRankValue = totalVoters; // If N voters, the highest rank is N
var minRankValue = 1; // The lowest rank is 1
for (var j = 0; j < numCandidates; j++) {
var currentCandidate = candidateData[j];
var currentCandidateRanks = currentCandidate.ranks;
var currentCandidateName = currentCandidate.name;
// Check if the ranks are a permutation of 1 to totalVoters, or similar logic
var sortedRanks = [].concat(currentCandidateRanks).sort(function(a, b){return a – b});
var isValidPermutation = true;
if (sortedRanks.length !== totalVoters) {
isValidPermutation = false; // Incorrect number of ranks
} else {
for (var k = 0; k < totalVoters; k++) {
if (sortedRanks[k] !== k + 1) {
isValidPermutation = false;
break;
}
}
}
if (!isValidPermutation) {
errorMessage += `The ranking numbers for ${currentCandidateName} are not a valid permutation of 1 to ${totalVoters}. Please ensure each number from 1 to ${totalVoters} appears exactly once.`;
// Continue calculation but warn the user
}
// Calculate Borda score for this candidate
for (var r = 0; r = 1 && rank maxScore) {
maxScore = bordaScores[candidateName];
winners = [candidateName]; // Start a new list of winners
} else if (bordaScores[candidateName] === maxScore) {
winners.push(candidateName); // Add to the list of winners (tie)
}
}
if (winners.length === 1) {
winner = winners[0];
resultDisplay.querySelector('span').innerText = winner + " with a score of " + maxScore;
} else if (winners.length > 1) {
winner = winners.join(', ') + " (It's a tie!) with a score of " + maxScore;
resultDisplay.querySelector('span').innerText = winner;
} else {
resultDisplay.querySelector('span').innerText = "No winner could be determined.";
}
resultDisplay.style.display = 'block';
}