Programming Questions

  • Newest
  • Popular Tags
  • Ask Question
  • Simple Symbols Question
    I'm not sure why the if statement keeps returning false. I'd appreciate any input. Challenge in question: <a href='coderbyte.com/CodingArea/Editor.php?ct=Simple%20Symbols&lan=JavaScript'>coderbyte.com/CodingArea/Editor.php?ct=Simple%20Symbols&lan=JavaScript<;/a> 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.