Hello folks!
I have a silly doubt about looping.
for (let i = 0; i < cats.length; i++) {
if (i === cats.length - 1) {
info += 'and ' + cats[i] + '.'; //why this line select the final index of the array???
} else {
info += cats[i] + ', '; // why this one select all the array???
}
}
Does anyone knows why one argument select just the final word of the array and the second select the whole array??for me both lines looks quite the same! It doesn’t make any sense to me
Thank you all!