javascript

🔒 문제 구분자가 .이 아니라 ' ' 공백이 여러개 들어왔을 경우에 뒤집는 풀이 🔑 풀이 (C++) #include #include using namespace std; string reverseWords(string S) { int endIndex = S.length(); string result = ""; while (endIndex > 0) { while (endIndex > 0 && S[endIndex--] == ' '); int startIndex = endIndex; while (startIndex > 0 && S[--startIndex] != ' '); if (startIndex != 0) { string word = S.substr(startIndex + 1, endIndex - start..
· Web
필수 패키지 설치 > npm init --y > npm i koa > npm i --save-dev typescript ts-node nodemon @types/koa @types/node ## 이 부분은 Visual Studio Code Plugin을 사용하면 굳이 추가설치 하지 않아도 되긴한당. > npm i --save-dev eslint eslint-config-prettier @typescript-eslint/parse ts-node: 트랜스파일링을 파일(.js)로 생성하지 않고 바로 메모리단에서 수행해주는 착한 친구다. ※ 패키지명에 @types/ 가 붙은 것은 TypeScript를 지원하는 패키지로 구글링해서 npm 패키지가 나오면 존재하는 것이다.! 그냥 바로 설치해주도록 하자. npm '..
1. index ; condition ; operation 아주 오래된, index , condition 을 명시한 for loop은 언어 어디에나 쓰여왔다 가령 다음과 같은 코드다. const array = ['a', 'b', 'c', 'd', 5]; for(let i=0 : i < array.length; i++) { console.log(array[i]) // 모든 원소 순서대로 iteration } // 출력결과: a b c d 5 2. for .. in C++, Java, Kotlinm 언어등에서도 흔히 배열 loop에 많이 쓰는 형태다. const array = ['a', 'b', 'c', 'd', 5]; for(let alphabet in array) { console.log(alphabet..
When to use 배열에서 특정 값에 대한 최종 합계를 구할 때 구문 array.reduce(callback, [intitialValue]) callback 각 배열 요소를 순회하며 실행할 함수 reduce( callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; Parameter Description previousValue 이전까지의 순회 값 currentValue 이번 항목의 값 currentIndex 이번 순회 회차 수 (Optional) array 순회 대상 배열 (Optional) accumulator 누산기, 콜백의 return value 누적. in..
문제 상황 JavaScript Object 내에 'Key'를 변수를 사용하여 할당하려 하는데 변수를 통한 키 할당이 이뤄지지않음. const targetKey = 'name'; const targetValue = 'mmm'; //아래 코드가 동작하지 않음. store.update({ targetKey : targetValue // name : 'mmm' 으로 인식하지 않고, // targetKey : 'mmm'으로 인식 }, { fields : [targetKey], limit : 1 }); 해결 방법 From ES5 operator bucket '[]'를 사용한다. 수정된 코드 const targetKey = 'name'; const targetValue = 'mmm'; store.update({ //..
· Web/FrontEnd
https://devlog.jwgo.kr/2016/10/16/bootstrap-css-not-working-properly/ 부트스트랩을 사용할 때 커스텀 CSS 레이아웃이 잘 적용되지 않는다면 · Tonic 사이트 운영에 도움을 주실 수 있습니다. 고맙습니다. --> 부트스트랩을 사용할 때 커스텀 CSS 레이아웃이 잘 적용되지 않는다면 2016년 10월 16일 주의! 아래 글 중 중괄호와 퍼센트 사인 사이의 공백은 실제 코드에서 제거되어야 합니다. jekyll 문법에서 인식 오류가 발생해 공백이 삽입되어 있습니다 부트스트랩 사이트에서 제공하는 기본 레이아웃에, 장고(Django)의 html 상속과 css 중첩 구조를 사용할 때 실수하기 쉬운 부분을 설명하기 devlog.jwgo.kr 자바스크립트(jav..
M_Falcon
'javascript' 태그의 글 목록