Answers for "a backwards counting forloop"

PHP
1

a backwards counting forloop

<?php
// a array
$weekday = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday", "Sunday");
// the for loop
for($i = 6; $i >= 0; $i = $i -1){ 
    print ( "$weekday[$i]<br>" );
}
?>
Posted by: Guest on December-19-2020
1

Count Backwards With a For Loop

var myArray = [];
for (var i = 9; i > 0; i -= 2){
    myArray.push(i);
}
console.log(myArray); // console output [ 9, 7, 5, 3, 1 ]
Posted by: Guest on December-21-2020

Browse Popular Code Answers by Language