목록분류 전체보기 (39)
고리타분한 개발자
목적 나열된 두 개의 문자열이 'anagram'인지 확인하기'anagram'은 하나의 문자열과 동일한 문자를 사용하는 경우를 말한다.사용되어진 문자의 갯수도 같아야 한다. 공백이나 기호가 아닌 문자만 관여 되어진다.대문자는 소문자와 동일하게 간주한다. example anagrams('rail safety', 'fairy tales') --> True anagrams('RAIL! SAFETY!', 'fairy tales') --> True anagrams('Hi there', 'Bye there') --> False 들어가기에 앞서const word = 'HI THERE!!!!!'word.replace(/[^\w]/g, '') // HITHEREword.replace(/[^\w]/g, '').toLower..
목적 배열과 나눌 단위가 주어지면, 하나의 배열 안에 단위만큼 내부 배열을 만들기. examplechunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]]chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]]chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]]chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]]chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]]1. ![ArrayChunking_1](./erMind/ArrayChunking_1.png) ```jsfunction chunk(array, ..
목적 1부터 n까지 출력하기. 단, 3의 배수에는 fizz. 5의 배수에는 buzz, 3과 5의 공배수에는 fizzbuzz 찍기 example fizzBuzz(5)12fizz4buzz 1. 우선, input 값이 3의 배수인지, 5의 배수인지, 3과 5의 공배수인지 확인해야 합니다. 3으로 나누어 떨어지면 3의 배수, 5로 나누어 떨어지면 5의 배수, 그리고 3과 5로 모두 나누어 떨어지면 공배수가 됩니다. function fizzBuzz(n) { for (let i = 1; i
목적 주어진 정수의 숫자가 역순으로 정렬된 새로운 정수를 반환하기. example reverseInt(15) === 51reverseInt(981) === 189reverseInt(500) === 5reverseInt(-15) === -51reverseInt(-90) === -9 들어가기에 앞서 const myNumber = 200myNumber.toString().split('') // ['2','0','0']myNumber .toString() .split('') .join('') // 200 Math.sign(4000) // 1Math.sign(-4000) // -1 parseInt(myNumber.toString()) / 2000 // 0.1 1. 주어진 숫자를 역순으로 반환시키는 방법은 간단합니..
목적 주어진 문자열이 회문(회기식)이면 true를 반환하고, 그렇지 않으면 false를 반환 example palindrome('abba') === truepalindrome('abcdefg') === false 1. 가장 기본적인 방법으로는 자바스크립트 내장함수인 'reverse'를 사용하여 구현 가능합니다. function palindrome(str) { const reversed = str .split('') .reverse() .join('') return str === reversed} 2. 만약 'reverse' 매소드를 사용할 수 없는 경우, every 매소드를 사용하여 구현할 수 있습니다. function palindrome(str) { return str.split('').every((c..
목적 문자열에서 각 단어의 첫글자를 대문자로 반환시키기 example capitalize('a short sentence') --> 'A Short Sentence' capitalize('a lazy fox') --> 'A Lazy Fox' capitalize('look, it is working!') --> 'Look, It Is Working!' 들어가기에 앞서 const word = 'there' word[0] // tword[0].toUpperCaer() // Tword.slice(1) // here const sentence = 'Hi there buddy!' sentence.split(' ') // ["Hi", "there", "buddy!"] 1. function capitalize(str)..
목적주어진 문자열에서 가장 많이 사용된 단어를 반환하기. example maxChar('abcccccccd') === 'c'maxChar('apple 1231111') === '1' 1. 일단 우리는 주어진 문자열을 쪼개서 각 문자가 몇번 사용 되었는지 확인할 수 있어야 한다. const string = 'Hello World!'const chars = {} for (let char of string) { console.log(chars) // 하단 주석처리 if (!chars[char]) { chars[char] = 1 } else { chars[char]++ }} // {}// {H: 1}// {H: 1, e: 1}// {H: 1, e: 1, l: 1 }// {H: 1, e: 1, l: 2 }// {..
목적주어진 문자열을 역순으로 정렬하여, 새 문자열을 반환하기. examplereverse('apple') === 'elppa'reverse('hello') === 'olleh'reverse('Greetings!') === '!sgniteerG' 1.가장 기본적인 방법으로는 자바스크립트의 내장함수인 'reverse'를 사용하여 구현할 수 있습니다. function reverse(str) { return str .split('') .reverse() .join('')} 2.만약 'reverse' 매소드를 사용할 수 없는 경우라면, 반복문을 사용하여 구현할 수 있습니다. function reverse(str) { let reversed = '' for (let character of str) { reverse..
이번에는 Tab을 만들어 보도록 하겠습니다. 일단 탭에 들어갈 내용들을 리스팅 해보도록 하겠습니다. DOCTYPE html> body { padding-top: 40px; } About About Us About Our Culture 리스팅 작업이 정상적으로 진행되면 bulma에서 tabs부분을 가져오도록 하겠습니다. Pictures Music Videos Documents bulma에서 가져온 코드를 우리가 만든 코드에 심어주면 DOCTYPE html> body { padding-top: 40px; } Here is the content for the about us tab. Here is the content for the about our culture tab. Here is the content ..
이번에는 modal 이용하여 컴포넌트 사용을 연습해 보려고 합니다.역시 bulma의 component-modal 부분을 사용해보도록 하겠습니다. (https://bulma.io/documentation/components/modal/) DOCTYPE html> body { padding-top: 40px; } Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque risus mi, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum felis venenatis effi..