G Giao Linh New member Sep 19, 2021 #1 What does the following JavaScript code snippet do? Code: data.sort(function(a,b),b-a); A. Sort in the alphabetical order B. Sort in the chronological order C. Sort in reverse alphabetical order D. Sort in reverse numerical order
What does the following JavaScript code snippet do? Code: data.sort(function(a,b),b-a); A. Sort in the alphabetical order B. Sort in the chronological order C. Sort in reverse alphabetical order D. Sort in reverse numerical order
D Danh Trịnh New member Sep 19, 2021 #2 Answer: d Explanation: ’a-b’ is used to sort the array in ascending order whereas ‘b-a’ is used to sort the array in descending order. Therefore the above code snippet sorts an array in reverse numerical order. Upvote 0 Downvote
Answer: d Explanation: ’a-b’ is used to sort the array in ascending order whereas ‘b-a’ is used to sort the array in descending order. Therefore the above code snippet sorts an array in reverse numerical order.