function insertionSort(arr) { for (let i = 1, n = 1; i < arr.length; i++) { n = i - 1; let current = arr[i] while(n >= 0 && arr[n] > current ) { let sibling = arr[n]; arr[n] = current; arr[n+1] = sibling; n--; } } return arr; }
- function insertionSort(arr) {
// return sorted array- for (let i = 1, n = 1; i < arr.length; i++) {
- n = i - 1;
- let current = arr[i]
- while(n >= 0 && arr[n] > current ) {
- let sibling = arr[n];
- arr[n] = current;
- arr[n+1] = sibling;
- n--;
- }
- }
- return arr;
- }
// TODO: Create method objectFreeze which works the same as native Object.freeze. // !IMPORTANT: You haven't use Object.freeze during your task function objectFreeze(obj) { [ ...Object.getOwnPropertyNames(obj), ...Object.getOwnPropertySymbols(obj) ].forEach(item => { const descriptor = Object.getOwnPropertyDescriptor(obj, item); if ( !descriptor.get || !descriptor.set) { Object.defineProperty(obj, item, { configurable: false, writable: false }) } }) return obj; }
- // TODO: Create method objectFreeze which works the same as native Object.freeze.
- // !IMPORTANT: You haven't use Object.freeze during your task
- function objectFreeze(obj) {
return Object.freeze(obj);- [ ...Object.getOwnPropertyNames(obj),
- ...Object.getOwnPropertySymbols(obj)
- ].forEach(item => {
- const descriptor = Object.getOwnPropertyDescriptor(obj, item);
- if ( !descriptor.get || !descriptor.set) {
- Object.defineProperty(obj, item, {
- configurable: false,
- writable: false
- })
- }
- })
- return obj;
- }