Javascript string index -


i working on javascript on website helps companies see how campaigns doing on 1 collective screen. using if statement separate of information when go check code says

string index out of range -1

here sample code:

var place = {media buy name};  if(place.indexof("prospecting")){     return "prospecting"; } else if(place.indexof("audiencetargeting")){     return "audiencetargeting"; } else if(place.indexof("retargeting")){     return "retargeting"; } else{     return "other"; } 

1) javascript case-sensitive. indexof not same indexof.

2) array , string have indexof method (1, 2). place plain object, has no indexof method, neither indexof.

therefore have make place variable either array or string. code work.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -