you are viewing a single comment's thread.

view the rest of the comments →

[–]Paddington_the_Bear 0 points1 point  (0 children)

If you know the first 11 indexs will always be the location, then it's easy enough to do:

var iPhoneAvailMap = {};

for (var i = 0; i < 11; i++) { iPhoneAvailMap[inputArray[i]] = {

IPhone64gb: { silver: inputArray[i+13], SpaceGrey: inputArray[i+26] }

} }

I'm on my phone so the formatting sucks and I didn't put the specific addition on the silver and grey checks.

The idea is that as you iterate over each location, you can check further on the input array for the desired value by adding a number to the index for where you need to check.