cli-prep
Version:
A fun and interactive command-line interview preparation game to test your programming knowledge with 80+ questions across multiple categories!
93 lines (82 loc) ⢠3.55 kB
JavaScript
// Feedback and analysis functions for the CLI Prep Game
export function getPersonalizedFeedback(score, total, playerName) {
const percentage = (score / total) * 100;
let performanceLevel, emoji, feedback, suggestions;
if (percentage >= 90) {
performanceLevel = "Outstanding";
emoji = "š";
feedback = `Exceptional work, ${playerName}! You're a programming wizard!`;
suggestions = [
"Consider taking on more advanced algorithms challenges",
"Try contributing to open source projects",
"Mentor others who are learning to code"
];
} else if (percentage >= 80) {
performanceLevel = "Excellent";
emoji = "š";
feedback = `Great job, ${playerName}! You have a solid understanding!`;
suggestions = [
"Focus on the areas where you missed questions",
"Practice more complex problem-solving scenarios",
"Review system design concepts"
];
} else if (percentage >= 70) {
performanceLevel = "Good";
emoji = "š";
feedback = `Well done, ${playerName}! You're on the right track!`;
suggestions = [
"Review the fundamentals in your weaker categories",
"Practice more coding problems daily",
"Study common algorithm patterns"
];
} else if (percentage >= 60) {
performanceLevel = "Fair";
emoji = "š";
feedback = `Nice effort, ${playerName}! There's room for improvement.`;
suggestions = [
"Focus on understanding basic concepts first",
"Practice coding problems regularly",
"Review data structures fundamentals"
];
} else if (percentage >= 40) {
performanceLevel = "Needs Improvement";
emoji = "šŖ";
feedback = `Keep going, ${playerName}! Everyone starts somewhere.`;
suggestions = [
"Start with basic programming concepts",
"Take online courses or tutorials",
"Practice simple coding exercises daily"
];
} else {
performanceLevel = "Keep Learning";
emoji = "š";
feedback = `Don't give up, ${playerName}! Programming is a journey!`;
suggestions = [
"Start with programming fundamentals",
"Find a mentor or study group",
"Practice basic syntax and concepts"
];
}
return { performanceLevel, emoji, feedback, suggestions };
}
export function getCategoryAnalysis(categoryStats, chalk) {
const analysis = [];
Object.entries(categoryStats).forEach(([category, stats]) => {
const percentage = (stats.correct / stats.total) * 100;
let status;
if (percentage >= 80) status = chalk.green("Strong šŖ");
else if (percentage >= 60) status = chalk.yellow("Good š");
else status = chalk.red("Needs Work š");
analysis.push(` ${chalk.cyan(category)}: ${stats.correct}/${stats.total} (${percentage.toFixed(0)}%) - ${status}`);
});
return analysis;
}
export function getMotivationalMessage(percentage, chalk) {
if (percentage >= 80) {
return chalk.yellowBright('\nš Keep practicing! You\'re doing great!');
} else if (percentage >= 60) {
return chalk.yellowBright('\nš Keep practicing! You\'re doing great!');
} else {
return chalk.redBright('\nš Keep studying and try again! Practice makes perfect!');
}
}