
The Duplicate Word Checker is a JavaScript-driven word counter that can detect how many times did you use one word in your article.
How to use it:
1. Code the HTML for the duplicate word check.
<form class="form">
<div class="wordArea">
<label class="label" for="word">Type Your Word To Check</label>
<input class="formInput" id="formWord" name="word" type="text" onkeydown="getValWord()">
</div>
<div class="textArea">
<label class="label" for="text">Your Text</label>
<textarea class="fromTextArea" id="formText" rows="4" cols="50" onkeydown="getValText()"></textarea>
</div>
<input class="fromButton" id="formButton" type="button" value="Check">
</form>
<!-- Result -->
<p class="containerFinderResult" id="formResult"></p>2. The main JavaScript to check how many times a word is repeated in your text.
// get least value word input
function getValWord() {
return document.getElementById('formWord').value;
}
// get least value textarea input
function getValText() {
return document.getElementById('formText').value;
}
//check logic code after onclick
const formButton = document.getElementById('formButton');
formButton.addEventListener('click', () => {
let repeatTime =
//if input was empty
getValText() == '' & getValWord() == '' ? 'no' :
//if input has value
getValText().split(' ').filter((text) => {
return text == getValWord().trim();
}).length;
document.getElementById('formResult').innerHTML = `your word repeated ${repeatTime} times`
});






