Received is an input of arrays:
var fruits = [["fuji", "apple"], ["gala", "apple"], ["navel", "orange"], ["valencia", "orange"]]
I have blank arrays created:
var apple = []
var orange = []
I'd like to sort the fruits into their arrays by getting the string out of the second array item and push to the array. Is there a way to take that string value in fruits[i][1] and relate it to the array of the same name (apple/orange)?
for (var i = 0; i < fruits.length; i++) {
fruits[i][1].push(fruits[i]) // not a thing
}
Desired output:
apple == [["fuji", "apple"], ["gala", "apple"]]
orange == [["navel", "orange"], ["valencia", "orange"]]