I am doing some schema javascipt/C# coding and I have a question. I am doing breadcrumb schema for a little more reference. My goal is to find somehow to increment counter to be even to k in this example, so I can stop a comma from showing on the last iteration on the foreach loop. Right now, obviously they both increment at the same rate. I am having the biggest brain fart on where to place (counter++) to get it to increment and then end up even after the for each is completed. Both starting integer values should be as is. Just changing the counter to 1 is not what I am looking for :) Also the counter has to be in the ForEach loop.
Pseudo code below:
k = 1;
counter = 0;
foreach(string str in array1)
{
Schema Code
Schema Code
for(i = 0; i > 0; i++)
{
k++
counter++ (not right location, but reference)
}
if(k < counter)
{
print a coma
}
else if(k >= counter)
{
print space
}
}
Updated: My code would be where position is. I dont have access to my code at this moment. But the for each runs through the number on positions there are on the page. Then at the last position it will not write the comma.
<script type="application/ld+json">
{
"context": "http://schema.org",
"type": "BreadcrumbList",
"itemListElement": [{
"type": "ListItem",
"position": 5,
}
}
</script>