Please can someone educate me on how to assign values to object properties correctly in the given scenario:
I am taking the value of a text area, splitting the value at a new line. I need to assign these split values to a property of an object in an array. See below code:
var items = [{}];
function process() {
var i = 0;
items.forEach((j) => {
j.self = document.getElementById('input').value.split('\n');
});
process() is called when a button is clicked.
In the console, I get the following:
Instead of key[0] for example having 10 self values as an array, I need a single value to be assigned to key[0] as the value of the self property. The second split needs to be assigned to key1.self for example.
Expected output would be like this (apologies if not totally accurate):
items[0]{self: split-string[0]},
items[1]{self: split-string[1]},
items[2]{self: split-string[2]},
And so forth...
Rather than (what is shown in the console):
items[0].self[0] = split-string[0];
items[0].self[1] = split-string[1];
items[0].self[2] = split-string[2];
If that makes sense, please can someone assist.

jwithj++? --- Edit: Why are you using a number and then attaching a property to it?