Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #javascript #reverse #loop
ADD COMMENT
Topic
Name
6+4 =