Plagiarism Checker
.container {
max-width: 800px;
margin: 0 auto;
text-align: center;
}
textarea {
width: 100%;
padding: 12px 20px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
background-color: #f8f8f8;
resize: none;
}
button {
background-color: #4CAF50;
color: white;
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
text-align: left;
}
const checkBtn = document.getElementById("check-btn");
const textArea = document.getElementById("text");
const resultDiv = document.getElementById("result");
checkBtn.addEventListener("click", function () {
const text = textArea.value.trim();
if (text.length === 0) {
alert("Please enter some text.");
return;
}
const uniqueWords = [...new Set(text.toLowerCase().match(/\b\w+\b/g))];
const plagiarismScore =
((text.length - uniqueWords.length) / text.length) * 100;
resultDiv.innerHTML = `
Plagiarism Score: ${plagiarismScore.toFixed(
2
)}%
`;
});