Home | Mailing List | Blog | Tutorial Videos

Arrays, Sorting, and Reversing

Consider the following two arrays and operations on them. What gets logged as a result of script execution ?

const ar = [5, 1, 3, 7, 25];
const ar1 = ar;
console.log(ar1.sort());
(
  [5, 25].indexOf(ar[1]) != -1 && 
  console.log(ar.reverse())
) || 
(
  ar[3] == 25 && console.log(ar)
);
console.log(ar1);

Select one: