I have an ordered array which looks like this:-
[-0.0020057306590257895, 50, 0.09598853868194843, 50, 0.19398280802292264, 49.99999999999999, 0.2919770773638969, 50]
What I would like to do is the following:
- Take each 'odd' entry and make it the 'key index in an object, which can be achieved by rounding the value and multiplying by 10 e.g. (Math.round(-0.0020057306590257895 * 10) should be index 0 and Math.round(0.09598853868194843 * 10) should be index 1 etc)
- Take the 'even' values and make them the corresponding values in the object.
So...
The above CSV file should return the following object:-
{
0: 50,
1: 50,
2: 49.99999999999999,
3: 50
}
Does anyone one know how I can parse this CSV to produce the required array using either jQuery or plain javascript?
{}is an "object" or "hash", these have key/value pairs.[]is an "array", it is just an ordered list, these do not have keys.