Skip to content

Commit 4cc6967

Browse files
fixed the search problem
1 parent 94a12a9 commit 4cc6967

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Public/word-count-calculator.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ <h2>Your text summary</h2>
4444
<input class="form-control me-2" type="search" placeholder="Enter a word to know its frequency..." id="searchText" aria-label="Search"/>
4545
<button id="searchButton" class="btn btn-primary my-2 mx-2" type="submit" >Search</button>
4646
<div id="frequency"></div>
47-
</div>
48-
49-
<div class="unique">
50-
5147
</div>
5248
<script src="../assets/Js/word-count-calculator.js"></script>
5349

assets/Js/word-count-calculator.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ function search(val,search){
3939
return count;
4040
}
4141

42-
function copy(val){
43-
return val;
44-
}
4542

4643
var textContent = document.getElementById("textcontent");
4744
var showWordCount = document.getElementById("countWord");
@@ -54,6 +51,7 @@ var frequency=document.getElementById("frequency");
5451
var copy=document.getElementById("copyButton");
5552
var paste=document.getElementById("pasteButton");
5653
let f=0;
54+
5755
longestWord.innerHTML=("<br>There is no text.");
5856
textContent.addEventListener("input", function(){
5957

@@ -76,15 +74,12 @@ if(l.length===0){
7674
else{
7775
longestWord.innerHTML=("<br>Longest Word: "+l.bold());
7876
}
79-
80-
longestWordlength.innerHTML=("<br>Length of "+l+" is: "+l.length);
8177
let text=this.value;
82-
searchText.addEventListener("input",function(){
83-
let word=this.value;
84-
f=search(text,word);
78+
longestWordlength.innerHTML=("<br>Length of "+l+" is: "+l.length);
8579
searchButton.addEventListener("click",function(){
80+
let word=searchText.value;
81+
f=search(text,word);
8682
frequency.innerHTML=("<br>"+word.bold()+" occurs "+f+" times(s) in the text.");
8783
},false);
88-
},false);
8984
}, false);
9085

0 commit comments

Comments
 (0)