Coderbyte Challenge 7
Need help with a function that checks if every letter in the string is bounded by '+' signs. The code provided seems to be returning incorrect results - it should return false for the input string below as 'k' is missing a right-hand side '+'. Any assistance would be appreciated.
str = '+f+++l+k=+'
alpha = 'abcdefghijklmnopqrstuvwxyz'
function SimpleSymbols(str) {
str = str.toLowerCase()
for (i=0 ; i<str.length ; i++) {
if (alpha.indexOf(str.charAt(i)) > 0 && i === 0) {
return false
}
else if (alpha.indexOf(str.charAt(str.length -1)) > 0) {
return false
}
else if (alpha.indexOf(str.charAt(i)) > 0 &&
(str.charAt(i-1) !== '+' || str.charAt(i+1) != '+')) {
return false
}
else {return true}
}
}