I would like to restore some of the content of restoredCommentObject, which is an object.
I would like to do so for every element into the object, but do I have to put a counter to do so or is there any way to do it in a better way (without using an useless counter)
let counter = 0;
const createRestoredComment = (restoredCommentObject) => {
restoredCommentObject.forEach(restoredShit => {
let restoredText = restoredCommentObject[counter].text;
let restoredId = restoredCommentObject[counter].id;
counter ;
})
CodePudding user response:
When doing the forEach, the convention is as follows:
const createRestoredComment = (restoredCommentObject) => {
restoredCommentObject.forEach(restoredShit => {
let restoredText = restoredShit.text;
let restoredId = restoredShit.id;
})
No need to use the index var.