Could use some assistance here as I believe I'm getting close to a solution,
I have a form object that needs updating based on matching keys with an imported object.
For example, form.title should be set to the value in article.title.
I've attempted the following, but I'm struggling with how to set this.form[key][value] to this.article[articleKey][articleValue].
Object.entries(this.form).forEach(([key, value]) => {
Object.entries(this.article).forEach(([articleKey, articleValue]) => {
if ([articleKey][0] === [key][0]){
//[value] = [articleValue];
//this.form[key][value]=this.article[articleKey][articleValue]
}
});
Any insights would be greatly appreciated, I'm new to JavaScript. I specifically want to update the data properties in the form without cloning the object and bring in all the data from the article object.
Response to a comment - example of the form
form: new Form({
title: '',
description: '',
earliest_date:'',
latest_date:'',
image_file_names:[]
})
Example of the Article object
{"id":21,
"owner_id":1,
"title":"test1",
"description":"Test It",
"earliest_date":"2020-06-01",
"latest_date":"2020-06-06",
"image_file_names":"[\"1593530083background.jpg\",
\"159353008520190713_085629.jpg\"]",
"physical_description":"Test 1"}