window in Javascript - 어디서든 접근이 가능한 전역객체 - browser window를 의미하고, browser window를 control 할 수있는 다양한 method 제공 - 내가 작성하는 코드들이 이 window object의 property가 된다. 그래서 특별한 경우를 제외하고는 window는 생략이 가능하다. 단, const와 let은 scope가 object내에 속하기에 global object property로는 사용할 수 없다. - window.close() window.open() window.innerHeight window.innerWidth 등을 사용해서 window창 제어가능. // 1. 단축키를 사용 handle close function 호출 functio..
original code. setPeople function 은 multiple rows의 선택과는 관계없이 선택된 row가 single row인지만 확인한다. 1. 리덕스에서 받아온 selectedRows의 element 들을 굳이 각자 따로 받아와서 variable을 만들 필요가 없다. 2. array를 map 으로 loop 해서 받아온 것을 다시 assign하는 과정에서 다시 array 로 assign 하는 과정을 불필요하게 거침. function setPeople(result: any) { setDropdownList(result.map((people:any) => ({ label : `${people.name}(${people.email})`, value : people.id }))); cons..
Javascript는 type을 쓰지 않으니 원치않는 결과를 가질 때가 있는데 이럴때 아주 간단하게 형변환을 하는 방법이 있다. number + string type "" 은 number to string type conversion string * 1 은 string to number conversion Example code let arr = [1, 2, 3]; console.log(typeof arr); //datatype: object console.log(typeof arr[1]); //datatype: number let changeToString = (arr + "").split(","); //number + "": changed to string console.log(changeToStri..
Solution in JavaScript const arr = [1, 3, 2, 6, 1, 2]; const k = 3; const n = arr.length; function Divisible_Sum_Pairs(n, k, ar) { let num = 0; for(let i = 0; i < n; i++) { //condition 'i < j' 는 i보다 j가 index number로서 우선할 수 없다는 의미지 값이 커야한다는 의미가 아님. //문제 제대로 읽기! for(let j = (i + 1); j < n; j++){ if((ar[i] + ar[j]) % k === 0){ // 계산순서위한 () 잊지말것. ++num; } } } console.log(num); } Divisible_Sum_Pairs(..
Solution in JavaScript const scores = [10, 5, 20, 20, 4, 5, 2, 25, 1]; function breakingRecords(scores) { let [max, min] = [scores[0], scores[0]]; //중복배열로 선언 let [maxCount, minCount] = [0, 0]; for (let i = 1; i max) { //array로 넣어야지... max = scores[i]; maxCount++ } if (scores[i] < min) { min = scores[i]; minCount++ } } return [maxCount, minCount]; //두개 이상의 ..
Question Given a square matrix, calculate the absolute difference between the sums of its diagonals. 2d array 의 서로 다른 두 개의 대각선 값의 Absolute difference 즉, 절대값을 결과로 보여주는 문제. For example, 1 2 3 4 5 6 9 8 9 (1 + 5 + 9) - (3 + 5+ 9) |15 - 17| the absolute difference is 2. Tip. 0 1 2 0 o x o 1 x o x 2 o x o 필요한 부분이 나오는 배열의 형태를 먼저 적어주고 그 형태가 나올 수 있는 loop의 형태를 고민해 본다. 2d Array는 loop를 적용시키면 Column(세로) 이 순..
- Total
- Today
- Yesterday
- Javascript Algorithm
- 알고리즘
- easy javascript algorithm
- C++
- 프로그래머스
- rest parameter
- spring boot application
- ... in Javascript
- javascript
- easy algorithm
- compareTo()
- java
- math.abs
- Object type casting
- string class in java
- HashMap
- algorithm
- hackerrank
- code refactoring
- math.max
- 프로그래머스 알고리즘문제
- hackerrank javascript
- 프로그래머스 알고리즘
- HackerRank Algorithm
- hackerrank solution
- Collection Framework
- hackerrank javascript solution
- equals()
- substring()
- repeat()
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |