본문 바로가기
728x90
반응형

JavaScript186

웹 애플리케이션의 생애주기(the lifecycle of a web application)_1. page-building from Secrets of the JavaScript Ninja 이번 글은 'Secrets of the JavaScript Ninja'의 'Chapter 2. Building the page at runtime'을 바탕으로 작성하였습니다. 핵심 Keywords 웹 애플리케이션 생애주기의 단계 웹 페이지를 만들기 위한 HTML code의 절차 JavaScript code의 실행 순서 이벤트를 활용하여 interactive한 page 만들기 event loop 사전 지식 체크! 브라우저는 HTML code가 짜인 대로 page를 생성하는가? 웹 애플리케이션은 한 번에 event를 몇 개 처리하는가? 브라우저가 event를 처리하기 위해 event queue를 쓰는 이유? 웹 애플리케이션 생애주기 내용을 본격적으로 살펴보기에 앞서 웹 애플리케이션의 대략적인 생애주기부터 살.. 2022. 4. 4.
모음 찾기(Find The Vowels) References 아래 링크의 강의 중 Section 13. Find The Vowels의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solutions & includes() // ver. 1. function vowels(str) { const splited = str.toLowerCase().split(""); let cnt = 0; for (let char of splited) { if ( char === "a" || char === "e" || char === "i" || char === "o" || char === "u" ) { cnt++; } } .. 2022. 4. 4.
피라미드(Pyramids) References 아래 링크의 강의 중 Section 12. Two Sided Steps - Pyramids의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function pyramid(n) { for (let stair = 1; stair 2022. 4. 4.
별 찍기(Printing Stars) References 아래 링크의 강의 중 Section 11. Printing Steps의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function steps(n) { let star = ""; let space = ""; for (let i = 1; i 0; --j) { space += " "; } console.log(star + space); space = ""; } } steps(5); for문 i로 n만큼 행을 만들고, for문 j로 열을 만든다. for문 i를 돌면서 star를 하나씩 증가시켜 나가고, for문 j를 돌면서 공백을 .. 2022. 4. 4.
첫 글자 대문자로 만들기(Sentence Capitalization) References 아래 링크의 강의 중 Section 10. Sentence Capitalization의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function capitalize(str) { const splited = str.split(" "); let res = []; for (let char of splited) { const splitedSubArr = char.split(""); let capitalized = splitedSubArr.shift().toUpperCase(); capitalized = splitedSubArr.u.. 2022. 4. 4.
애너그램(Anagrams) References 아래 링크의 강의 중 Section 9. Anagrams의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. simpler ver. with RegExp // my solution function anagrams(stringA, stringB) { const sortedStringA = stringA.split("").sort().join("").toLowerCase(); const sortedStringB = stringB.split("").sort().join("").toLowerCase(); return sortedStringA === sorted.. 2022. 4. 4.
배열 잘라내기(Array Chunking) References 아래 링크의 강의 중 Section 8. Array Chunking의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function chunk(array, size) { const resArr = []; for (let i = 0; i el.length >= 1); } console.log(chunk([1, 2, 3, 4, 5], 4)); 결.. 2022. 4. 4.
fizzBuzz References 아래 링크의 강의 중 Section 7. The Classic FizzBuzz!의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function fizzBuzz(n) { let arr = []; for (let i = 1; i 2022. 4. 4.
문자열 내 최빈값 구하기(MaxChars) References 아래 링크의 강의 중 Section 6. MaxChars의 내용을 추려 이번 글을 작성하였습니다. The Coding Interview Bootcamp: Algorithms + Data Structures on Udemy Solution 1. my solution function maxChar(str) { const splited = str.split(""); let cnt = ""; const cntArr = []; for (let i = 0; i splited[i] === el).length; cntArr.push(cnt); } const maxCnt = [...cntArr].sort(.. 2022. 4. 4.
728x90
반응형