Answers for "loop js reverse return twic"

C#
8

how to reverse loop in javascript

const array = [6,7,8,9,10];
for (const number of array.reverse()) {
    console.log(number);
}
Posted by: Guest on March-25-2020
0

javascript reverse loop

const items = ["apricot", "banana", "cherry"];

for (let i = items.length - 1; i >= 0; i -= 1) {
  console.log(`${i}. ${items[i]}`);
}

// Prints: 2. cherry
// Prints: 1. banana
// Prints: 0. apricot
Posted by: Guest on February-17-2022

C# Answers by Framework

Browse Popular Code Answers by Language