코딩 테스트/CroCoder

문제 JavaScript DOM - Code Exercises | CroCoder The DOM or the Document Object Model of the page is created after the web page is loaded. Learn some DOM manuipulation with these exercises. www.crocoder.dev 메모 Document.getElementById()는 주어진 문자열과 일치하는 id 속성을 가진 요소를 찾고, 이를 나타내는 엘리먼트 객체를 반환한다. ID는 문서 내에서 유일해야 하기 때문에 특정 요소를 빠르게 찾을 때 유용하다. document.getElementById(id); innerHTML은 엘리먼트 내에 포함된 HTML 또는 XML ..
문제 JavaScript DOM - Code Exercises | CroCoder The DOM or the Document Object Model of the page is created after the web page is loaded. Learn some DOM manuipulation with these exercises. www.crocoder.dev 메모 querySelectorAll()은 지정된 셀렉터 그룹에 일치하는 다큐먼트의 엘리먼트 리스트를 나타내는 정적(살아 있지 않은)인 NodeList를 반환한다. // 클래스가 "note" 또는 "alert"인 모든 엘리먼트의 목록을 반환 var matches = document.querySelectorAll("div.note, div.alert..
문제 JavaScript DOM - Code Exercises | CroCoder The DOM or the Document Object Model of the page is created after the web page is loaded. Learn some DOM manuipulation with these exercises. www.crocoder.dev 메모 Document.querySelector()는 제공한 선택자 또는 선택자 뭉치와 일치하는 문서 내 첫 번째 Element를 반환한다. 일치하는 요소가 없으면 null을 반환한다. Document.createElement()는 지정한 tagName의 HTML 요소를 만들어 반환한다. tagName을 인식할 수 없으면 HTMLUnknownEle..
문제 JavaScript DOM - Code Exercises | CroCoder The DOM or the Document Object Model of the page is created after the web page is loaded. Learn some DOM manuipulation with these exercises. www.crocoder.dev 메모 Document.querySelector()는 제공한 선택자 또는 선택자 뭉치와 일치하는 문서 내 첫 번째 Element를 반환한다. 일치하는 요소가 없으면 null을 반환한다. Document.createElement()는 지정한 tagName의 HTML 요소를 만들어 반환한다. tagName을 인식할 수 없으면 HTMLUnknownEle..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 메모 Object.keys() // 배열 속 객체 요소의 합 const objects = [{ x: 1 }, { x: 2 }, { x: 3 }]; const sum = objects.reduce((acc, cur) => acc + cur.x, 0); // 초기값 0 필수 console.log(sum); // 6 정답 const e..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 메모 // 배열 속 객체 요소의 합 const objects = [{ x: 1 }, { x: 2 }, { x: 3 }]; const sum = objects.reduce((acc, cur) => acc + cur.x, 0); // 초기값 0 필수 console.log(sum); // 6 정답 const products = [ { ..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 메모 처음에는 students 객체 안에 있는 scores의 이름과 값을 변경하는 식으로 답에 접근했지만, 어느 순간 이게 비효율적 방법이란 사실을 깨닫고 방향을 틀었다. map으로 원하는 객체 이름을 정해 반환하는 식으로 코드를 작성하면 코드가 더 간결해진다. map으로 return을 사용하려면 중괄호로 감싸야 한다. 사실 화살..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 메모 Array.prototype.flat(): Node.js 11 버전부터 사용 가능. 예전에 작업하던 프로젝트 때문에 코드 에디터가 Node.js 10 버전으로 설정되어 있어서 처음에 flat을 쓰니 에러가 발생했다. 정답 const input = [ ["a", "b", "c"], ["c", "d", "f"], ["d", "f..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 메모 Array.prototype.fill() Array.prototype.map() // Arrow function map((element) => { /* … */ }) map((element, index) => { /* … */ }) map((element, index, array) => { /* … */ }) // Callb..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = "Every developer likes to mix kubernetes and javascript"; const answer = input.split(" ").map(x => (x.length > 3 ? (x = x.split("")[0] + (Number(x.length) - 2) + x.spli..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = [ { name: "John", age: 13, }, { name: "Mark", age: 56, }, { name: "Rachel", age: 45, }, { name: "Nate", age: 67, }, { name: "Jennifer", age: 65, }, ]; const arr = input..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = "George Raymond Richard Martin"; const arr = input.split(" "); console.log(arr.map(x => x[0]).join("")); const input = "George Raymond Richard Martin"; const arr = inpu..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = [12, 46, 32, 64]; const mean = input.reduce((a, b) => a + b) / input.length; const median = Math.round(mean); console.log(`{mean : ${mean}, median : ${median}}`); const..
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = [1, -4, 12, 0, -3, 29, -150]; console.log(input.filter(x => x > 0).reduce((a, b) => a + b));
문제 Map, Filter, Reduce - Code Exercises | CroCoder Map, filter and reduce are the most useful array methods to manipulate arrays and often the hardest to master. Try to solve the given exercises! www.crocoder.dev 정답 const input = [1, 2, 3, 4, 5]; console.log(input.map(x => Math.pow(x, 2)));
카버
'코딩 테스트/CroCoder' 카테고리의 글 목록