I would like to spilt the string by '|' and ':' and end up with an object with a key value relationship inside of an array.
It would look like this
[{key1 : red, key2 : five},{key1 : blue, key2 : six},{key1 : yellow, key2 : nine}, {key1 : black, key2 :ten}]
This is what I have so far
var x = "red:five|blue:six|yellow:nine|black:ten"
datesArray = [],
datesObj = {},
keys = ['key1','key2'],
dates = x.split('|');
for (var i = 0; i < dates.length; i++) {
datesArray.push(dates[i].split(':'));
}
for(var x = 0; x < datesArray.length; x++){
datesObj[keys[0]] = datesArray[x][0]
datesObj[keys[1]] = datesArray[x][1]
}
console.log(datesObj);
Any help is appreciated !