array reverse algorithm in js
let array1 = ["yes", "no", "maybe", "always", "sometimes", "never", "if"];
let array2 = [5,8,2,9,5,6,3,1];
function reverseArray(arr) {
var newArray = [];
for (var i = arr.length - 1; i >= 0; i--) {
newArray.push(arr[i]);
}
return newArray;
}
reverseArray(array1); // ["if", "never", "sometimes", "always", "maybe", "no", "yes"]
reverseArray(array2); // [1, 3, 6, 5, 9, 2, 8, 5]
Also in JavaScript:
- javascript get all elements with class
- arithmetic expressions in scheme
- elemente alphabetisch sortieren javascript
- what is eval in js
- creating react app using npx
- mobile nav react npm
- hot to start cypress
- difference between == and === in javascript
- javascript set div height
- click doesn't work on ajax loaded data
- Postfix increment
- js for of loop
- switch19 dynamically update js
- react native maps api key
- syntax to call item from array
- composer require friendsofcake/crud-json-api for cakephp3 version
- res : [ Circular ] nodejs
- angular generate component without spec
- if else condition on hide and show in jquery
- path object d3.js
- js html textarea tag access
- args slice discord.js
- $(getJson) returning error
- chart js rotating the x axis labels