function insertionSort(arr) { const filtered = [] arr.forEach(item => { const index = filtered.findIndex(c => c > item) index === -1 ? filtered.push(item) : filtered.splice(index, 0, item) }) return filtered }
- function insertionSort(arr) {
// return sorted array- const filtered = []
- arr.forEach(item => {
- const index = filtered.findIndex(c => c > item)
- index === -1 ? filtered.push(item) : filtered.splice(index, 0, item)
- })
- return filtered
- }
function objectFreeze(a) { Object.getOwnPropertySymbols(a).concat(Object.getOwnPropertyNames(a)).forEach(key => { Object.defineProperty(a, key, {configurable: false, writable: false, value: a[key]}) }) return a }
// TODO: Create method objectFreeze which works the same as native Object.freeze.// !IMPORTANT: You haven't use Object.freeze during your taskfunction objectFreeze(obj) {return Object.freeze(obj);- function objectFreeze(a) {
- Object.getOwnPropertySymbols(a).concat(Object.getOwnPropertyNames(a)).forEach(key => {
- Object.defineProperty(a, key, {configurable: false, writable: false, value: a[key]})
- })
- return a
- }