0

Please consider this structure:

          1   |    2     |    3    | ....
----------------------------------------------------------
2016      100     2000       500
2015      540     450        1200
2014      120     230        660

I want to assign this values to an variable and access to value such this way: MyVar[2016][2] or call a function that return the value for year:2016 and month:2.

What is the best solution to convert that data to structure that can assign it to a variable?

0

1 Answer 1

5

var MyVar = { "2014": [0, 120, 230, 660], "2015": [0, 540, 450, 1200], "2016": [0, 100, 2000, 500] };
console.log(MyVar["2016"][2]); //2000

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.