“tableau inversé JavaScript” Réponses codées

numéro inversé javascript

// Function to reverse Number
function reverseNum(n) {
  let r = n.toString().split('').reverse().join('');
  return Math.sign(n) * parseInt(r);
}

// Call
reverseNum(-267);
reverseNum(31522);

// Outputs
-762
22513
Kaotik

tableau inversé JavaScript

var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
Black Footed Ferret

JS Array Nest inversé

var reversed = array.map(function reverse(item) {
    return Array.isArray(item) && Array.isArray(item[0]) 
               ? item.map(reverse) 
               : item.reverse();
});
Jolly Jackal

Array Algorithme inversé dans 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]
Salo Hopeless

Comment inverser un tableau

        int[] xr = {1, 2, 3, 4, 5};

        System.out.print("[");
        for (int i = xr.length - 1; i >= 0; i--) {
            System.out.print(xr[i] + ", ");
        }
        System.out.println("\b\b]");
    }
Chathumal Sangeeth

tableau inversé JavaScript

const array1 = ['one', 'two', 'three'];
// expected output: "array1:" Array ["one", "two", "three"]

const reversed = array1.reverse();
// expected output: "reversed:" Array ["three", "two", "one"]
liad

Réponses similaires à “tableau inversé JavaScript”

Questions similaires à “tableau inversé JavaScript”

Plus de réponses similaires à “tableau inversé JavaScript” dans JavaScript

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code