Hello, I'm in the process of creating a looping pattern based on the conditions of the array object key. If the 'o' contains 't', the index will start from the 'n' starting point in the object, otherwise, the numbering will continue from the main counter.
Here is the data array:
let data = [
{o:[],n:1}, // An empty 'o' could be our main counter, which can also be dynamic or any number to start
{o:[],n:1},
{o:['t'],n:1}, // 't' present, so start numbering from n
{o:['t'],n:1},
{o:[],n:1}, // continue the numbering from the main counter
{o:[],n:1},
{o:['t'],n:1},
{o:[],n:1},
{o:[],n:1},
{o:['t'],n:5},
{o:['t'],n:5},
{o:['t'],n:5},
{o:[],n:1},
]
When I execute this code:
recount(data){
for (var i = 0; i < data.length; i++) {
// Code implementation here
// Note that new values can also modify data[i].n
console.log(**numbering**)
}
}
Expected output:
//numbering
//1,2,1,2,3,4,1,5,6,5,6,7,7
Thank you for your assistance!