전체 글
-
Git hub 으로 과제 clone 및 제출 하기 / remote 활용 팁!concept/CLI, git hub 2020. 4. 1. 12:46
Git hub에서 내 컴퓨터로 과제 clone 하기 cd /Desktop //Desktop 으로 이동 mkdir codestates //codestates 파일 생성 cd codestates //codestates 파일로 이동 git clone url //git에서 복사한 url clone ls //현재 폴더 파일 리스트 cd PRE-JavaScriptKoans //PRE-JavaScriptKoans 파일로 이동 code . //파일 열기 내 컴퓨터에서 변경된 파일 Git hub으로 commit 하고 pull하기 git status // 어떤 것이 변경되었는지 확인하기 (modified로 뜬다.) git add 변경된 파일 // 변경된 파일을 추가 git commit -m 'completed 변경된 파일..
-
Command Line Interface (CLI)concept/CLI, git hub 2020. 4. 1. 12:19
Command Line Interface(이하 CLI)는 Graphic User Interface(이하 GUI)와 대조되는 개념. CLI : 표준 입출력 시스템(Standard I/O)을 통한 입력과 그에 따른 결과를 출력 GUI : 마우스와 각종 UI 컴포넌트, 터치를 이용한 직관적인 프로그램의 형태 ls 폴더 파일 리스트 쫙 나옴(list) al 디테일한 정보 보기 cd 디렉토리로 이동 pwd 현재 디렉토리 확인 cd ~ 홈 디렉토리 cd / 루트 디렉토리 (시스템의 최상위 디렉토리) cd . 현재 디렉토리 cd . . 부모 디렉토리 파일 이름에 공백이 있을 때는? tab 으로 자동완성 또는 My\ Documents로 역슬래시 사용 touch [file_name] 빈 파일 생성 mkdir [dir_n..
-
[ ] === [ ] // false? 참조 타입(reference type)이란?concept/javascript 2020. 3. 31. 19:05
[] === [] 를 콘솔 창에서 찍어보았을 때, 결과 값은 false 가 나온다. 왜 그럴까? 이것을 원시 타입(primitive type) 과 참조 타입(reference type) 이라는 개념을 통해 알아볼 수 있다. 원시 타입(primitive type) 참조 타입(reference type) number, string, Boolean, null, undefined, symbol 객체(object), 배열(array), 함수(function) 먼저 원시 타입(primitive type)에 대한 설명이다. 1 === 1 // true 'hello' === 'hello' // true true === true // true 그리고 참조 타입(reference type)에 대한 설명이다. [] === ..
-
.bind 를 이용한 템플릿 만들기concept/javascript 2020. 3. 31. 16:49
function template(name, money){ return '' + name + '' + money + ''; } template('ohyeon', 100); //ohyeon100 여기서 .bind를 활용해서 name을 템플릿으로 고정시켜보자. let tmplOhyeon = template.bind(null, 'ohyeon'); tmplOhyeon(100) //--> ohyeon100 tmplOhyeon(200) //--> ohyeon200 이렇게 money의 값만 변수로 지정하는 함수를 새로 만들 수 있다. 그렇다면? money를 고정시키고 name만 변하게 만들 수는 없을까?
-
Array.prototype.indexOf() vs String.prototype.indexOf()concept/javascript 2020. 3. 31. 16:38
Array.prototype.indexOf() const beasts = ['ant', 'bison', 'camel', 'duck', 'bison']; console.log(beasts.indexOf('bison')); // expected output: 1 // start from index 2 console.log(beasts.indexOf('bison', 2)); // ** index 2에서부터 찾아라! // expected output: 4 console.log(beasts.indexOf('giraffe')); // expected output: -1 String.prototype.indexOf() const paragraph = 'The quick brown fox jumps over the l..
-
의사코드로 알고리즘 문제를 해결하는 방법concept/data structure 2020. 3. 30. 18:58
예를 들어 텍스트에서 foo라는 단어를 찾아 전부 다른 단어로 바꿔주는 코드를 작성한다고 가정해본다. 다음은 pseudocode의 예제이다. 텍스트를 입력으로 받는다 foo라는 단어를 찾는다 그 단어를 지운다 그 자리에 새로운 단어를 넣는다 바뀐 내용을 리턴한다 아래는 코드로 작성한 예제 이다. function replaceFoo(text) { // foo라는 글자의 index가 -1이 아니면 단어를 찾은 것이다 while( text.indexOf('foo') !== -1 ) { // index를 발견하면 let index = text.indexOf('foo'); // index를 이용해 foo 바로 앞까지의 텍스트를 얻어내고 let beforeText = text.slice(0, index); // f..
-
재귀 함수(recursion)concept/javascript 2020. 3. 30. 18:42
재귀: 함수를 스스로 호출하는 것 function foo(){ foo(); } 대표적인 예시는 !(팩토리얼)이다. function factorial(n){ if(n === 0){// ** 재귀는 무한 반복을 방지하기 위해 반드시 탈출 조건이 있어야 한다!!! ** return 1; } return n * factirial(n - 1); } 기본적으로 반복문이므로, 모든 재귀는 반복문으로 표현할 수도 있다. function factorial(n){ let result = 1; for(let i = n; i > 0; i--){ result = result * i; } return result; } 대표적인 두 번째 예시는 피보나치 수열 이 있다. 피보나치 수열이란? 0, 1, 1, 2, 3, 5, 8, 13..