File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Step By Step
2
+ function ExOh ( str ) {
3
+ // First, we declare two variables:
4
+ // One which remove all characters in the string that aren't x's...
5
+ var strX = str . replace ( / [ ^ x ] / g, '' ) ;
6
+
7
+ // ...and and the second which removes all characters that aren't o's
8
+ var strO = str . replace ( / [ ^ o ] / g, '' ) ;
9
+
10
+ // Next, we get the length of each of these new variables to determine how many x's and o's are in the string...
11
+ var xNumber = strX . length ;
12
+ var oNumber = strO . length ;
13
+
14
+ // ...and return the truth value of comparing the two.
15
+ return xNumber === oNumber ;
16
+ }
17
+
18
+ // No Comments
19
+ function ExOh ( str ) {
20
+ return str . replace ( / [ ^ x ] / g, '' ) . length === str . replace ( / [ ^ o ] / g, '' ) . length ;
21
+ }
You can’t perform that action at this time.
0 commit comments