Skip to content
Advertisement

Putting multiple values as single strings into object

I have an object values:

JavaScript

I need to extract the stringValues and put them into another object obj as a value to the key ghi. The final result should look like that:

JavaScript

My approach is :

JavaScript

But the result doesn’t look quite right:

JavaScript

As you can see, it puts both values as 1 string.

Fiddle: https://jsfiddle.net/zrx0sp76/

Advertisement

Answer

Well if you want it be an array, then declare it as an array and push() values to it.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement