I want to cycle through an array of strings and split those strings on a certain character, and then feed those new strings into an array, ex. take the string "val: key" from the first array and then use a function to retrieve the string from the array and split it on ":" into a new array that would contain ["val","key"]. This is what I have so far, and at the bottom is what is returning when console.log it.
var dict = [];
dict.push("me; pro: myself");
dict.push("labor, laboris; n: work");
dict.push("voco, vocare, vocavi, vocatum; v: call");
function parseDict(arr){
/* parseDict takes a dictionary entry and splits it between its latin part and its part of speech/english translation*/
var dictFinal = [];
arr.toString();
for (i = 0; i < arr.length; i++){
dictFinal[i] += arr[i].split(";");
}
return dictFinal;
}
console.log(parseDict(dict)) prints out
[ 0: "undefinedme; pro: myself"
1: "undefinedlabor, laboris; n: work"
2: "undefinedvoco, vocare, vocavi, vocatum; v: call"
]
Why is it not splitting into two strings on the ";", and why is it returning an undefined value?
dictFinal.push(...)ordictFinal[i] = ...arr.toString();makes no sense