Cost if Living Calculator

Real-Time Content Analyzer

Word Count
0
SEO Score
0%
Density
0%
function analyzeSEOContent() { var text = document.getElementById('seo-input-text').value; var keyword = document.getElementById('seo-keyword').value.toLowerCase(); var resultsDiv = document.getElementById('seo-results'); if (!text) { alert('Please enter some text to analyze.'); return; } resultsDiv.style.display = 'block'; var words = text.trim().split(/\s+/).filter(function(w) { return w.length > 0; }); var wordCount = words.length; var charCount = text.length; var keywordCount = 0; if (keyword.length > 0) { var regex = new RegExp('\\b' + keyword + '\\b', 'gi'); var matches = text.match(regex); keywordCount = matches ? matches.length : 0; } var density = wordCount > 0 ? ((keywordCount / wordCount) * 100).toFixed(2) : 0; var score = 0; var feedback = ""; if (wordCount > 300) score += 30; if (wordCount > 600) score += 20; if (keywordCount > 0) score += 20; if (density >= 0.5 && density <= 2.5) score += 30; if (wordCount < 300) { feedback += "• Content is too short. Aim for at least 300 words.
"; } else { feedback += "• Good word count length.
"; } if (keyword.length > 0) { if (keywordCount === 0) { feedback += "• Target keyword not found in text.
"; } else if (density > 3) { feedback += "• Keyword density is high (" + density + "%). Watch out for keyword stuffing.
"; } else { feedback += "• Excellent keyword density.
"; } } else { feedback += "• Provide a target keyword for deeper analysis.
"; } document.getElementById('res-words').innerText = wordCount; document.getElementById('res-score').innerText = score + "%"; document.getElementById('res-density').innerText = density + "%"; document.getElementById('res-feedback').innerHTML = feedback; }

Leave a Comment