-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (21 loc) · 801 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const textValue = document.getElementById("textarea");
const wordCount = document.getElementById("wordCount");
const charCount = document.getElementById("charCount");
const clear = document.getElementById("clear");
textValue.addEventListener("input",function(){
// textValue.classList.toggle("p");
let userText = this.value;
// console.log(userText)
charCount.textContent = ` and ${userText.length} character`;
let word = userText.split(" ");
// console.log(word)
let newWord = word.filter((Ele)=>Ele !== "");
// console.log(newWord);
wordCount.textContent = `You have written ${newWord.length} Word`;
})
clear.addEventListener("click",()=>{
charCount.textContent = "";
wordCount.textContent= "";
textValue.value = "";
location.reload();
})