We can create a single variable that contains string data, which this string data holds several data separated by comma.
For example, I create this string: “Andy,New York,28,Journalist”. This single string contains 4 data separated by comma. Now the problem is how to extract this 4 data from it?
The answer is using JavaScript “split” function. Here is the sample code:
var myString = "Andy,New York,28,Journalist";
var separatedData = myString.split(",");
var data1 = separatedData[0];
var data2 = separatedData[1];
var data2 = separatedData[2];
var data2 = separatedData[3];
By using split() function I’ve created an array variable, that each one of it indexes contains separated string data respectively. In above example, data1 which is separatedData[0] contains “Andy” and data2 contains “New York” and so on.