Have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once(ie. "lane borrowed" would result in true because there is exactly three characters between a and b).Otherwise return the string false.
Ab Check Coderbyte Java
Ab Check Coderbyte Python
Ab Check coderbyte JavaScript
Using the JavaScript language, have the function ABCheck(str) take the str parameter being passed and return the string true if the characters a and b are separated by exactly 3 places anywhere in the string at least once (ie. "lane borrowed" would result in true because there are exactly three characters between a and b). Otherwise, return the string false.
I am going to use a RegExp to see if the pattern [a...b] exists anywhere in the string. If it does then return true else return false. *
Steps for solution
1) Use RegExp pattern to search string for pattern a...b
2) If found return true
3) Else return false
Disclaimer: The above Problem is generated by Coderbyte but the Solution is provided by ShouterFolk.