DEV Community

Cover image for JavaScript Quiz Question #1: Array Sort Comparison
Nick Scialli (he/him)
Nick Scialli (he/him)

Posted on

JavaScript Quiz Question #1: Array Sort Comparison

Consider the following arrays. What gets logged in various sorting conditions?

const arr1 = ['a', 'b', 'c'];
const arr2 = ['b', 'c', 'a'];

console.log(
  arr1.sort() === arr1,
  arr2.sort() == arr2,
  arr1.sort() === arr2.sort()
);
Enter fullscreen mode Exit fullscreen mode

A) true true true
B) true true false
C) false false false
D) true false true

Put your answer in the comments!

Oldest comments (19)

Collapse
 
yavuztor profile image
Yavuz Tor

B

Collapse
 
javaarchive profile image
Raymond

D?

Collapse
 
ivanesko69 profile image
Ivo

D

Collapse
 
goncalomendes profile image
Gonçalo Oliveira

B

Collapse
 
avxkim profile image
Alexander Kim

B

Collapse
 
harshrajk profile image
harshrajk

B

Collapse
 
vladdekhanov profile image
Dekhanov Vladislav

I guess the correct answer is B

Collapse
 
andrewslobodianiuk profile image
Andrew Slobodianiuk

B

Collapse
 
vanbui1995 profile image
vanbui1995

B

Collapse
 
cloudmunk profile image
CloudMunk • Edited

B, morning coffee does wonders.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.