Skip to content

Commit 6e70b7c

Browse files
word and char bug solve
1 parent b41ee25 commit 6e70b7c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

project-1/project-app/src/components/TextForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default function TextForm(props) {
7777
</div>
7878
<div className="container my-4" style={{color: props.mode ==='dark' ? 'white' : 'black'}}>
7979
<h2>your text summary</h2>
80-
<p>{text.split(" ").length} words and {text.length} characters </p>
80+
<p>{text.split(/[^\s]+/).length - 1} words and {text.replace(/ /g,"").length} characters </p>
8181
<p>{0.008 * text.split(" ").length} Minutes read</p>
8282
<h2>Preview</h2>
8383
<p>{text.length > 0 ? text: "Enter something in the above textBox"}</p>
@@ -88,6 +88,7 @@ export default function TextForm(props) {
8888

8989

9090

91+
// text.split(" ").length
9192

9293
// let newText = () =>{
9394
// let newString = "";

0 commit comments

Comments
 (0)