I have stored a set of strings in an array in JavaScript. When I tried to retrieve the first string from that array by using indices, it retrieves the first character instead of the first string.
How do I get the entire string in the first index of the array, instead of getting the characters?
Here is the code:
var name=["hello","avr","karthik","ajay"];
var count=-1;
function begin(which) {
if(which==0){
if(count==0){
count=3;
}
else{
count--;
}
}
else{
count++;
if(count>3){
count=0;
}
}
var message=document.getElementById("message");
message.innerHTML=name[count];
}