Programming Questions

  • Newest
  • Popular Tags
  • Ask A Question
  • Simple Symbols Question
    I'm not sure why the if statement keeps returning false. I'd appreciate any input. Challenge in question: http://coderbyte.com/CodingArea/Editor.php?ct=Simple%20Symbols&lan=JavaScript
    function testCase(sen) { 
    
    var pat = /.[a-z]./gi;
    var loc = sen.match(pat);
    
    for (var i=0; i<loc.length; i++) {
        if (loc[i] == /\u002B[a-z]\u002B/i ){
            sen = true;    
        } else {
            sen = false;
            break;    
        }
    }
    
     return sen;
    };
    
    DrummerTrades posted this question on 9/20/14 | javascript
    Answers
  • +
  • 1
  • -
  • I think you want your if statement to be:
     if( /\u002B[a-z]\u002B/i.test(loc[i]) ) 
  • +
  • 0
  • -
  • Maybe try using the
    String.match()
    instead of directly comparing the string with a regex?
    Log in to write an answer.