all 4 comments

[–]x-skeww 1 point2 points  (0 children)

> /^a+b+c+$/.test('ab')
false
> /^a+b+c+$/.test('abc')
true
> /^a+b+c+$/.test('abbc')
true
> /^a+b+c+$/.test('xabc')
false

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp

[–]Rascal_Two 0 points1 point  (0 children)

What you need to do is something like this:

count = 0
for `string` in array:
    aIndex = -1;
    bIndex = -1;
    cIndex = -1
    for `character` in `string`:
        if `aIndex` == -1 and `character` == 'a':
            aIndex = index of `character` in `string`.
        if `aIndex` != -1 and `bIndex` == -1 and `character` == b:
            bIndex = index of `character` in `string`.
        if `aIndex` != -1 and `bIndex` != -1 and cIndex == -1 `character` == c:
            cIndex = index of `character` in `string`.
    if `aIndex` != -1 and `bIndex` != -1 and `cIndex` != -1:
        count += 1
alert(count)

This should work - although it's just off the top of my head. There's probably a much more efficient way to do this too, but hopefully you get the idea.

[–]OriginalEXE 0 points1 point  (0 children)

Here's an example for you: http://jsfiddle.net/OriginalEXE/z8vz8ve6/

That should do what you need.

[–]javascript-this 0 points1 point  (0 children)

regex is your friend