Coding problem solution not working

Here’s is my working code!
@ilenia 's suggestion seems to have fixed my code.

Here’s my final code (it was accepted as an answer by edabit)
I’m using @snowmonkey 's regex to get know if a letter is an alphabet.

function plusSign(string) {
	if (string[0]!="+" || string[string.length-1]!="+") {
		return false;
    }
    i = 1;
    for (index in string) {
        console.log(index, string[Number(index)-1]);
        console.log(index, string[Number(index)]);
        console.log(index, string[Number(index)+1]);
        if (string[index].match(/[a-z]/i)) {
            if (string[index-1] && string[Number(index)+1]) {
                if (string[index-1]=="+" && string[Number(index)+1] == "+") {
                    continue;
                }
                else {
                    return false;
                }
            }
        }
    }
    return true;
    
}

plusSign("+d+k+##f+");
plusSign("hf+d++#+f+")
plusSign("+abcdef+");

Thanks a lot, it works now! I feel very good, even though it took, a day and spoon-feeding of what I needed to do.
I like the approach of not just giving the working solution!

1 Like

Please suggest improvements!

1 Like

And also, thank you everyone for the help!!

1 Like

Glad you worked it out, and less spoon-feeding than you think. We gave guidance, but the heavy lifting was all you. Very well done!

If you back up a few responses, I’d posted a repl with this problem solved in two ways, one based on my original thinking and one following yours. Both approaches are valid, but it is interesting to examine more than one way up the mountain.

Congrats!

Thank you!

I didn’t even have a look at it!!!

Thanks!

1 Like

This is how you guys helped me (watch it, it’ll be worth it)

Just watch it don’t read the title - I can tell u it’s a YouTube video

2 Likes

when you have issues, console.log everything, and make sure it does what you think it does, it helps a lot

2 Likes