javascript reverse array
var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
javascript reverse array
var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
javascript flip array
//reverse() reverses the order of the elements in an array.
//reverse() overwrites the original array.
const fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.reverse();
console.log(fruits); // ['Mango', 'Apple', 'Orange', 'Banana']
.reverse javascript
const array1 = [1,2,3,4];
console.log('array1:', array1);
//"array1:" Array [1, 2, 3, 4]
const reversed = array1.reverse();
console.log('reversed:', reversed);
//"reversed:" Array [4, 3, 2, 1]
// Careful: reverse is destructive -- it changes the original array.
console.log('array1:', array1);
//"array1:" Array [4, 3, 2, 1]
reverse array
#include<iostream>
using namespace std;
int main()
{
int arr[100], tot, i, j, temp;
cout<<"Enter the Size for Array: ";
cin>>tot;
cout<<"Enter "<<tot<<" Array Elements: ";
for(i=0; i<tot; i++)
cin>>arr[i];
cout<<"nThe Original Array is:n";
for(i=0; i<tot; i++)
cout<<arr[i]<<" ";
j = tot-1;
for(i=0; i<j; i++, j--)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
cout<<"nnThe Reverse of Given Array is:n";
for(i=0; i<tot; i++)
cout<<arr[i]<<" ";
cout<<endl;
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us