Junior — Senior
Sorting only the odd elements of the array
livecode
Task condition
It is necessary to write a function sortOdd that sorts all odd numbers in the given array in ascending order, without changing the positions of even numbers.
function sortOdd(array) {
return;
}
console.log(sortOdd([7, 1])); // [1, 7]
console.log(sortOdd([5, 8, 6, 3, 4, 41])); // [3, 8, 6, 5, 4, 41]
console.log(sortOdd([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])); // [1, 8, 3, 6, 5, 4, 7, 2, 9, 0]