const array = ['blastoff', 1, 2, 3];
for (let index = array.length - 1; index >= 0; index--) {
const element = array[index];
console.log(element);
}
Run code snippet
const array = ["a", "b", "c"];
for (const str of array.reverse()) {
console.log(str)
}
let reverseArray = Arr=>{
let pushed =[];
for(let i = Arr.length -1; i >= 0; i--){
pushed.push(Arr[i]);
}
return pushed
}
const sentence = ['sense.','make', 'all', 'will', 'This'];
console.log(reverseArray(sentence))
// Should print ['This', 'will', 'all', 'make', 'sense.'];
var array = [1,2,3,4];
//array stores a set of arguments, which in this case are all numbers
var totalArguments = array.length;
//totalArguments stores the total number of arguments that are in the array
//To get the arguments of the array to display in reverse we will -
// first have to subract 1 to totalArguments because to access the -
// arguments of an array they start from 0 to the total number of -
// arguments-1, which in this case would be totalArgumenst = 4 -
// 4 - 1 = 3 , so we are going to display 0 to 3 with a for loop
for (var i = totalArguments - 1 ; i >= 0 ; i--) {
console.log(array[i]);
}
ar arr = [1, 2, 3, 4, 5];
Object.keys(arr).reverse()
.forEach(function(index) {
console.log(arr[index]);
});
var arr = [1, 2, 3, 4, 5];
arr.slice().reverse()
.forEach(function(item) {
console.log(item);
});
var arr = [1, 2, 3, 4, 5];
for (var i = arr.length - 1; i >= 0; i--) {
arr[i]
}
for (i = array.length - 1; i >= 0; i--) {
code
}
var arr = [1, 2, 3];
arr.slice().reverse().forEach(function(x) {
console.log(x);
})
var arr = [ 1, 2, 3, 4, 5,
arr.slice().reverse().forEach(function(item { consoloe.log(item);});
for(let i = 0; i < arr.length; i++){
console.log(arr.slice(arr.length-10-i, arr.length-i))
}
/*
arr is [0, 1, 2, 3, ..., 199, 200]
VM1088:2 (10) [191, 192, 193, 194, 195, 196, 197, 198, 199, 200]
VM1088:2 (10) [190, 191, 192, 193, 194, 195, 196, 197, 198, 199]
VM1088:2 (10) [189, 190, 191, 192, 193, 194, 195, 196, 197, 198]
VM1088:2 (10) [188, 189, 190, 191, 192, 193, 194, 195, 196, 197]
VM1088:2 (10) [187, 188, 189, 190, 191, 192, 193, 194, 195, 196]
VM1088:2 (10) [186, 187, 188, 189, 190, 191, 192, 193, 194, 195]
VM1088:2 (10) [185, 186, 187, 188, 189, 190, 191, 192, 193, 194]
VM1088:2 (10) [184, 185, 186, 187, 188, 189, 190, 191, 192, 193]
VM1088:2 (10) [183, 184, 185, 186, 187, 188, 189, 190, 191, 192]
VM1088:2 (10) [182, 183, 184, 185, 186, 187, 188, 189, 190, 191]
*/
var arr = [1, 2, 3, 4, 5];
for (var i = arr.length - 1; i >= 0; i--) {
console.log(arr[i]);
}
var arr =[1,2,3]
for(let element of arr.reverse()){
console.log(element)
}