javascript - Multiple else if with indexOf -


i have following code:

var aaaa = exploded[1];  if (aaaa.indexof("bbbb")>=0) { //do here } 

everything works great, when add:

else if (aaaa.indexof("cccc")>=0) { //do else } else if (aaaa.indexof("dddd")>=0) { //do else 2 } else if (aaaa.indexof("eeee")>=0) { //do else 3 } 

i message "aaaa undefined" , code wont run. how can fix this?

thanks

edit: commenting curly braces mistake when wrote here in stacoverflow, has nothing issue. solved issue removing lost curly brace inside first else if. problem solved!

works fine:

var aaaa = "bbbb";  if (aaaa.indexof("bbbb")>=0) {      alert('aa') ; } else if (aaaa.indexof("cccc")>=0) {      alert('cc'); } else if (aaaa.indexof("dddd")>=0) {      alert('dd'); } else if (aaaa.indexof("eeee")>=0) {      alert('ee'); } 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -