Here's a JavaScript code snippet that sorts an array of n numbers in ascending order. I've used this code in several interviews, but I'm still unsure about which sorting algorithm it represents.
let arr = [7, 9, 2, 11, 5]
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[j] < arr[i]) {
let temp = arr[i]
arr[i] = arr[j]
arr[j] = temp
}
}
}
console.log(arr) //[2, 5, 7, 9, 11]