so here is the code
var searchValue = "Dans-Test";
if ( searchValue.indexOf('-') >= 0 ){
searchValue.replace('-', ' ');
console.log("reached here");
} else {
console.log("no -");
}
console.log(searchValue);
searchValue is still outputting Dan-Test and not Dan Test, why?
it does console log reached here so the if statement is correct
thanks
Returns a new string with some or all matches of a pattern replaced by a replacement. The pattern can be a string or a RegExp, and the replacement can be a string or a function to be called for each match.developer.mozilla.org/en/docs/JavaScript/Reference/…