Examine the following code:
x = [40, 10, 30, 20, 50]; x.sort(cmp);
How should the function cmp
be declared if, after the code execution, the elements of the array x
are sorted in ascending order?
let cmp = (a, b) => b - a;
let cmp = (a, b) => b < a;
let cmp = (a, b) => b > a;
let cmp = (a, b) => a - b;
More Questions: JavaScript Essentials 1 – JSE1: Final Test
Please login or Register to submit your answer