I am trying to build a json from values so that I can push it to an object. I have two items as below.
var item1 = "2"
var item2 = "Student"
I am trying to build a json as below
{ "2" : "student"}
I tried couple of ways but ran out of ideas. Is there an easy way or any lodash method to do it.
Use ES6 computed properties like:
{ [item1]: item2 }