File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ /***************************************************************************************
2
+ * *
3
+ * CODERBYTE BEGINNER CHALLENGE *
4
+ * *
5
+ * AB Check *
6
+ * Using the JavaScript language, have the function ABCheck(str) take the str *
7
+ * parameter being passed and return the string true if the characters a and b are *
8
+ * separated by exactly 3 places anywhere in the string at least once *
9
+ * (ie. "lane borrowed" would result in true because there is exactly three characters *
10
+ * between a and b). Otherwise return the string false. *
11
+ * *
12
+ * SOLUTION *
13
+ * I am goint to use a RegExp to see if the patter [a...b] exists anywhere in the *
14
+ * string. If it does then return true else return false. *
15
+ * *
16
+ * Steps for solution *
17
+ * 1) Use RegExp pattern to search string for pattern a...b *
18
+ * 2) If found return true *
19
+ * 3) Else return false *
20
+ * *
21
+ ***************************************************************************************/
22
+ function ABCheck(str) {
23
+
24
+ var match = str.search(/a...b/);
25
+ if (match > -1) {
26
+ return "true";
27
+ }
28
+ else {
29
+ return "false";
30
+ }
31
+
32
+ }
You can’t perform that action at this time.
0 commit comments