렛츠기릿 자바스크립트

    렛츠기릿 자바스크립트 6 (끝말잇기)

    HTML 1번째 참가자 제시어: 입력 Index.js const number =parseInt(prompt("몇 명이 참가하나요?"), 10) const $button = document.querySelector('button'); const $input = document.querySelector('input'); const $word = document.querySelector('#word') const $order = document.querySelector('#order') let word; //제시어 let newWord; //새로 입력한 단어 const onClickButton = ()=>{ if(!word || word[word.length-1]===newWord[0]){ //제시어가 비어 ..

    렛츠기릿 자바스크립트 5

    선택자 : id선택자(#), 태그 선택자, 클래스 선택자(.클래스) document.querySelector('선택자') : 1개의 태그만 선택 (가장 첫번째만 선택) document.querySelectorAll('선택자') : 여러 개 태그선택, 리턴 타입이 객체(유사배열) -NodeList document.querySelector('#order') : 고유한 id선택자 1개만 선택한다. document.querySelector('div>span') : div태그의 바로 밑에 있는 자식만 선택한다. document.querySelectorAll('div span') : div태그 안에 있는 자손"들" span을 찾아라 document.querySelectorAll('body #target button..

    렛츠기릿 자바스크립트4 (함수, 객체)

    함수 function(){ } //또는 () =>{ } 함수에 이름 붙이기 function a() { } 함수 선언문(세미콜론 없음)-오래된 관습 const b = function() { }; 함수 표현식 const c = ( ) => { }; 화살표 함수 return은 함수를 종료 시킨다. function c() { return 'hello'; console.log('h1'); } c() hello h1는 출력이 안된다.(함수가 이미 종료 되었으므로) 함수에 return문이 없는 경우 "return undefined"가 생략된 것이다. 배열로 리턴하기 function a(){ return [1, 5] } parameter와 argument function a(paremeter){ } a(argument..

    렛츠기릿 자바스크립트3 (배열의 메서드)

    객체의 유형: 배열, 함수, 배열이나 함수가 아닌 객체 배열 기본 const fruits = ['사과', '오렌지', '배', '딸기']; const arrayOfArray=[[1, 2, 3], [4, 5]]; arrayOfArray[0] = [1, 2, 3] 배의 내부의 값은 중복 되어도 되고, 아무 값이 없는 배열도 만들 수 있습니다. const everything = ['사과', 1, undefined, true, '배열', null, '']; const duplicated = ['가', '가', '가', '가', '가']; const empty=[]; const target = ['나', '다', '라', '마', '바']; 가장 첫번째 요소를 추가하고 싶은 경우 target.unshfit('가'..