Skip to content

Instantly share code, notes, and snippets.

@Smakar20
Created September 11, 2017 19:10
Show Gist options
  • Save Smakar20/559b4d11d91c58fddc82760e71cd2770 to your computer and use it in GitHub Desktop.
Save Smakar20/559b4d11d91c58fddc82760e71cd2770 to your computer and use it in GitHub Desktop.
null created by smakar20 - https://repl.it/Kovh/2
/*Have the function simpleSymbols(str) take the str parameter being passed and determine if it is an acceptable sequence by either returning the string true or false. The str parameter will be composed of + and = symbols with several letters between them (ie. ++d+===+c++==a) and for the string to be true each letter must be surrounded by a + symbol. So the string to the left would be false. The string will not be empty and will have at least one letter.*/
(function simpleSymbols(str){
let regExp = /^[A-z]+$/
if(str.length == 1){
if(str.match(regExp)) return false
return true
}
if(str[0].match(regExp) || str[str.length-1].match(regExp)) return false
for(let i = 0; i < str.length; i++){
if((str[i].match(regExp) && str[i-1] != "+") || (str[i].match(regExp) && str[i+1] != "+")) return false
}
return true
}("+a+1+a+==="))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment