I have a question about this loop
var c = [0,1,2,3,4,5,6,7,8,9];
for(var j=0;j<c.length;j++){
console.log(c[j]);};
if i put it this way
var c = [0,1,2,3,4,5,6,7,8,9];
for(var j=0;j<c.length;j+=2){
console.log(c[j]);};
It increases me by two, but what I want to know is if there is a way that instead of increasing it, I throw two values in the same console.log in this way
console.log(c[j],c[j]);
//0 1
//2 3
and so on.
You could access the current index of the loop and the current index + 1 to display it in the loop
console.log
. Then you would have to modify the index so that it continues traversing the index,array
skipping the index + 1 that you already printed inconsole.log
it (so that it does not print 0 1, 1 2, 2 3, 4 5...)If you are looking to go through a JSON Array, this example can help you, the answer per se was already given by @phpMyGuel
Complement what you are looking for