Skip to content

Commit 90d4aa7

Browse files
committed
Create AB Check
1 parent 34f231c commit 90d4aa7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

AB Check

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy