0

I have

const value = [`123`, `232`, `789`, `554`, `990`] const year = ['2015', '2016', '2017', '2018', '2019'] 

with these two arrays, I'm trying to make an object like this.

[ {value: '123', year: '2015'}, {value: '232', year: '2016'}, {value: '789', year: '2017'}, {value: '554', year: '2018'}, {value: '990', year: '2019'}, ] 

How can I make this thing possible?

I tried to use map(), however failed.

5
  • map() is a fine way to do it. Why did it fail? Commented May 27, 2022 at 15:26
  • value and year always have the same amount of elements? Commented May 27, 2022 at 15:29
  • stackoverflow.com/questions/42448966/… got the same problem. I figured out how to do it. Thank you guys! Commented May 27, 2022 at 15:36
  • 1
    this is an example of how you can do it with .map jsfiddle.net/kenpy/e0gfm54k/5 Commented May 27, 2022 at 15:39
  • Wow This looks easier than the link upon. Thank you Chris. Commented May 27, 2022 at 15:47

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.