-
[알고리즘/자바스크립트] 삼각형 판별문제 (Is this a triangle?)Algorithm 2019. 2. 18. 21:55
-해당 문제는 codewars사이트의 level7 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Implement a method that accepts 3 integer values a, b, c. The method should return true if a triangle can be built with the sides of given length and false in any other case. (In this case, all triangles must have surface greater than 0 to be accepted). Test.describe("PublicTest", function() { Test.assertEquals(isTriangle(1,2,2), t..
-
[알고리즘/자바스크립트] 완벽한 제곱근 구하기 (Find the next perfect square!)Algorithm 2019. 2. 18. 00:08
-해당 문제는 codewars사이트의 level7 문제입니다. (1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] You might know some pretty large perfect squares. But what about the NEXT one? Complete the findNextSquare method that finds the next integral perfect square after the one passed as a parameter. Recall that an integral perfect square is an integer n such that sqrt(n) is also an integer. If the parameter is itself not a perfect squa..
-
[jQuery] 제이쿼리 5일차 요점정리Frontend 2019. 2. 17. 22:22
-입력 요소 제어- [1] 값 설정하기 $("셀렉터").val('내용'); [2] 값 읽어오기 # text, select(드롭다운)var input = $("셀렉터").val(); 드롭다운 요소의 경우 사용하지 않는 태그라 하더라도 value 속성값을 부여해야 한다. ---선택하세요--- item1 # 라디오 버튼의 경우셀렉터가 여러 개를 의미하는 경우이므로 그 중에서 선택된 항목만 지정하는 셀렉터를 사용해야 한다.라디오는 하나만 선택 가능하므로 가져온 결과 자체는 단일 값이다. var input = $("셀렉터: checked").val(); # 체크 박스의 경우checked 가상 클래스를 통해 가져온 대상이 배열 상태가 되므로 이를 반복문으로 처리해야 한다.배열의 요소는 선택된 체크박스들에 대한 HT..
-
[jQuery] 제이쿼리 4일차 요점정리Frontend 2019. 2. 17. 22:16
-요소의 탐색- [1] 메서드 체인하나의 jQuery요소에 대하여 메서드를 연속적으로 호출하는 기법.특별한 경우가 아닌 이상 jQuery()의 함수들은 객체 자신을 리턴한다. $("#foo").attr(key, value) .css(key, value) .addClass(cls) .click(function() {}); [2] 주변 요소 탐색하기 함수설명prev()이전 요소를 리턴한다.next()다음 요소를 리턴한다.parent()상위 요소를 리턴한다.children()하위 요소(들)을 리턴한다.eq(n)n번째 요소를 리턴한다. [3] 부모 요소 얻기: 주어진 셀렉터를 갖는 가장 인접한 부모 요소를 리턴한다.$("#foo").parents("셀렉터"); [4] 자식 요소 얻기: 주어진 셀렉터를 갖는 가장..
-
[jQuery] 제이쿼리 3일차 요점정리Frontend 2019. 2. 17. 22:15
- 요소의 판별 - [1] index() 함수 : 특정 요소가 부모 태그 안에서 갖는 인덱스 번호를 리턴하는 함수 (0부터 시작함) ... --->0 --->1 --->2 [2] $(this) : 복수 요소에 대한 이벤트에 전달된 콜백함수 안에서 이벤트가 발생한 주체를 의미하는 객체 button1 button2 button3 [3] HTML 요소의 속성 제어 특정 요소에 적용되어 있는 속성값 조회하기var foo - $("#bar").attr("속성이름"); 특정 요소에 적용하기개별 적용$("#bar").attr('속성이름', '값); 일괄 적용 (JSON 형태 사용)$("#bar").attr({ 속성이름: '값', 속성이름: '값', 속성이름: '값' ... }); 속성 이름에 공백이나 - 기호가 포함..
-
[jQuery] 제이쿼리 2일차 요점정리Frontend 2019. 2. 17. 22:11
[1] jQuery 이벤트 처리 웹 브라우저가 HTML요소를 인식한 후에 처리되어야 하므로 jQuery의 load 처리 안에서 정의한다.이벤트는 함수 형태로 정의되어 있고, 해당 이벤트가 발생한 경우 호출될 함수를 콜백 파라미터로 전달한다.콜백함수에는 이벤트의 정보를 갖는 e 객체가 전달된다.필요한 경우 이 객체를 선언하고 활용할 수 있다.e.preventDefault()는 링크의 href 속성이나 폼의 submit 등에 대해서 HTML 요소가 수행해야 하는 기본 동작을 차단하는 역할을 한다. //jQuery의 load 처리 안에서 정의 $(function() { $("#foo").이벤트이름(function([e]) { [e.preventDefault();] });}); [2] 마우스 관련 (클릭 이벤트..
-
[JS] 자바스크립트 7일차 요점정리Frontend 2019. 2. 17. 22:07
-HTML 제어(2)- #요소 제어 ...javascriptvar myimg = document.getElementById("img요소의 id"); my img.src = "이미지 파일 경로";myimg.width = "200px";myimg.height = "100px";... #요소 제어 요소의 객체 획득하기 id 속성값으로 접근하는 경우var myform = document.getElementById("form_id"); name 속성값으로 접근하는 경우var myform = document.form_name; 획득한 안의 요소 접근 id 속성값으로 접근하는 경우var hello = document.getElementById("input_id"); name 속성값으로 접근하는 경우var myform..
-
[JS] 자바스크립트 6일차 요점정리Frontend 2019. 2. 17. 22:05
-URL 제어하기- 브라우저의 현재 URL 조회var now_url = location.href; 브라우저의 현재 페이지를 지정된 URL로 이동한다.window.location = 'URL'location.href = 'URL' 현재 페이지를 새로고침한다.location.reload(); 웹 브라우저 history의 이전 페이지로 이동한다.history.back(); 웹 브라우저 history의 다음 페이지로 이동한다.history.forward(); -웹 브라우저의 정보 조회- : 웹 브라우저의 이름, 버전정보, 운영체제 정보 등이 포함된 문자열 값 var agent = navigator.userAgent; 이 값에 특정 단어가 포함되어 있는지 여부를 판단하여 브라우저나 운영체제 종류, 모바일/PC 여..
-
[알고리즘/자바스크립트] 특정문자 공백으로 치환해서 return하기 (Dubstep)Algorithm 2019. 2. 17. 13:26
-해당 문제는 codewars사이트의 level6 문제입니다.(1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them. Let's assume that a song consists of some number of words (that don't contain WUB). To make the dubstep remix of this song, Polycarpus ..
-
[알고리즘/자바스크립트] 최소값 구하기 / 단어 중 가장 길이가 짧은 단어의 length를 구하기 (Shortest Word)Algorithm 2019. 2. 17. 11:59
-해당 문제는 codewars사이트의 level7 문제입니다.(1~8단계 중 8단계가 가장 쉬운 레벨)- [문제] Simple, given a string of words, return the length of the shortest word(s).String will never be empty and you do not need to account for different data types. Test.describe("Example tests",_=>{Test.assertEquals(findShort("bitcoin take over the world maybe who knows perhaps"), 3);Test.assertEquals(findShort("turns out random test cas..