Untitled
unknown
plain_text
2 years ago
1.4 kB
4
Indexable
// Define the qualities and their weights let qualities = [ { name: "kindness", weight: 0.3 }, { name: "generosity", weight: 0.25 }, { name: "empathy", weight: 0.2 }, { name: "integrity", weight: 0.15 }, { name: "resilience", weight: 0.1 } ]; // Function to determine someone's character function determineCharacter() { let totalScore = 0; // Calculate the score for each quality for (let i = 0; i < qualities.length; i++) { let quality = qualities[i]; let score = getRandomScore(); let weightedScore = score * quality.weight; totalScore += weightedScore; print(quality.name + ": " + score); } // Calculate the overall character score let characterScore = Math.round(totalScore * 100) / 100; // Map the character score to descriptive labels let characterLabel = ""; if (characterScore >= 80) { characterLabel = "Excellent"; } else if (characterScore >= 60) { characterLabel = "Good"; } else if (characterScore >= 40) { characterLabel = "Average"; } else { characterLabel = "Needs improvement"; } // Output the character score and label print("Character Score: " + characterScore); print("Character Label: " + characterLabel); } // Function to generate a random score between 0 and 100 function getRandomScore() { return Math.floor(Math.random() * 101); } // Call the function to determine someone's character determineCharacter();
Editor is loading...