I have the following code:
function header(){
experience += '';
var expimage = '';
for(var cik=0;cik<experience.length;cik++){
switch(experience[cik]){
case '0':
expimage += 'img0';
break;
case '1':
expimage += 'img1';
break;
case '2':
expimage += 'img2';
break;
case '3':
expimage += 'img3';
break;
case '4':
expimage += 'img4';
break;
case '5':
expimage += 'img5';
break;
case '6':
expimage += 'img6';
break;
case '7':
expimage += 'img7';
break;
case '8':
expimage += 'img8';
break;
case '9':
expimage += 'img9';
break;
}
}
document.getElementById('level').innerHTML = expimage;
alert(expimage);
}
But it only work on chrome or mozilla. It shows up an empty alert box, but it work on firefox and chrome. I tried to alert each variable after each line, and I noticed that the problem shows when I tried to alert(experience[0]) ,it shows undefined, the other steps are working.