localeCompare()를 사용하면 두 문자열을 쉽게 비교할 수 있다. const solution = (strings, n) => { let answer = strings.sort((a, b) => { if (a[n] === b[n]) { return a.localeCompare(b); } else { return a[n].localeCompare(b[n]); } }); return answer;}
slice기존 배열을 건드리지 않고 새배열 생성 (얕은 복사) splice기존 배열을 수정함 const solution = (num_list, n) => { let answer = []; while (num_list.length) { answer.push(num_list.splice(0, n)) } return answer;} splice를 사용하여 num_length값이 점점 줄어들고 2차원 배열을 만들게 된다.
참고https://youtu.be/DZs5JR2DLgc?si=X3rWjq6WX949ix1Z조합식 활용하여 풀기5개중 3개를 고르는 경우의 수 -> 5p3/3! => 10 문제 풀이const solution = (balls, share) => { let answer = 1; while (share > 0) { answer *= balls / share; balls--; share--; } return Math.round(answer);} floor가 아니라 round로 반올림 해주는 것이 포인트floor로 했더니 일부 문제 오답되었음 (부동소수점 때문에 그런거 아닐까 추측)
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Proxy Proxy - JavaScript | MDN Proxy 객체를 사용하면 한 객체에 대한 기본 작업을 가로채고 재정의하는 프록시를 만들 수 있습니다. developer.mozilla.org https://ko.javascript.info/proxy Proxy와 Reflect ko.javascript.info Proxy란? 특정 객체에 대한 가로채기 동작을 제공하는 내장 객체 객체의 동작을 수정하거나 전달함 프록시 생성 const proxy = new Proxy(target, handler) Proxy get & set 예제 let target = { gree..
참고 https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API HTML Drag and Drop API - Web APIs | MDN HTML Drag and Drop interfaces enable applications to use drag-and-drop features in browsers. developer.mozilla.org https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/File_drag_and_drop File drag and drop - Web APIs | MDN HTML Drag and Drop interfaces enable web ..