묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
깃헙 권한 요청
인프런 아이디 : notenore@gmail.com인프런 이메일 : notenore@gmail.com깃헙 아이디 : notenore@gmail.com깃헙 Username : notenore
-
미해결함수형 프로그래밍과 JavaScript ES6+ 응용편
DB Insert관련
강의들으면서 공부할겸 게시판을 만들고 있는데예를 들어 이런 식의 html이 있고<input id='title'/><textarea id='content'/><button onclick="onSave">save</button> 실제 코드는 다른데 대략적으로 이런식의 자바스크립트 코드가 있다고 치면async onSave(event) { const param = { title: document.getelementByID('title').value, content: document.getelementByID('content').value } await _.go( [param], _.each(v => { //validation 함수 if (!v.title) {alert('title을입력하세요'); throw new Error(message);} } ), v=>insertData({data:v}), //db insert method _.tap(v=>{ alert('데이터저장성공'); location.href='list.html'; //게시글 작성후 list페이지로 redirect }) ) }이렇게 go에서 validation이나 redirect함수를 넣는것과아래처럼 따로 빼네는것async onSave(event) { const param = { title: document.getelementByID('title').value, content: document.getelementByID('content').value } if(!param.title) { alert('title을입력하세요'); return ; } await _.go( [param], v=>insertData({data:v}), _.tap(v=>{ alert('데이터저장성공') }) ) location.href='list.html'; }둘중 어떤것을 더 선호하고 효율적인지 알고싶습니다.
-
해결됨자바스크립트 알고리즘 문제풀이 입문(코딩테스트 대비)
for문에 있는 DFS
function solution(n, m) { let answer = []; let tmp = Array.from({ len function DFS(L, s) { if (L === m) { answer.push(tmp.slice( } else { for (let i = s; i <= n tmp[L] = i; console.log(tmp); DFS(L + 1, s + tmp[L]); } } } DFS(0, 1); return answer; } console.log(solution(4, 2));강사님 저는 강의 보기전에 i + 1이 아닌 s + tmp[L]로 하니까 정답이 나오더라구요, 이렇게 해도 문제가 없 는 코드인가요?
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
코드 샌드박스처럼 코드를 받을 수 있나요?
섹션6 페이지구현-홈 수강중인데제가 코드 쳤을때18:29 오늘의일기1~5가 아에 안 나타나서 프롭으로 빈배열로 보내도안보여서 18분까지 다시 3번 들었는데ㅠㅠ 제가 실수한 곳을 아무리 찾아봐도 안보여서혹시 코드를 따로 받을 수 있을까요???
-
해결됨Vue.js 완벽 가이드 - 실습과 리팩토링으로 배우는 실전 개념
git hub 권한 수락 부탁드립니다.
인프런 아이디 : riffjq000@gmail.com인프런 이메일 : riffjq000@gmail.com깃헙 아이디 : dheornr0322@naver.com깃헙 Username : ohdaekuk 댓글 남겼는데 수락이 안되어있어서 다시 부탁 드립니다!
-
해결됨비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지
nginx 에러
강사님처럼 코드 쓰면 이런화면이나오고 delete하고 다시해보면 밑에 화면처럼 나옵니다.. 무슨 문제일까요이런화면이나오네요
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
깃헙 권한 요청
인프런 아이디 : kimnamkyu@lgcns.com인프런 이메일 : kimnamkyu@lgcns.com깃헙 아이디 : formanship@gmail.com깃헙 Username : manstar1201
-
미해결처음 만난 리액트(React)
npm start 후 빈화면
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. npm start 후 작성한 코드가 실행되지 않고 빈화면 띄는데 어떻게 해야할까요?구글링 해본 결과 package.json 파일에 "homepage="." 추가하면된다고하는데,,,(제가 참고한 블로그입니다.리액트 빌드 결과 빈화면만 보일때 - 상대경로 설정하기 (tistory.com))일단 index.html 파일에 있는 내용 첨부해드립니다.. <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="theme-color" content="#000000" /> <meta name="description" content="Web site created using create-react-app" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <!-- manifest.json provides metadata used when your web app is installed on a user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ --> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <!-- Notice the use of %PUBLIC_URL% in the tags above. It will be replaced with the URL of the `public` folder during the build. Only files inside the `public` folder can be referenced from the HTML. Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> <title>React App</title> </head> <body> <noscript>You need to enable JavaScript to run this app.</noscript> <div id="root"></div> <!-- This HTML file is a template. If you open it directly in the browser, you will see an empty page. You can add webfonts, meta tags, or analytics to this file. The build step will place the bundled scripts into the <body> tag. To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> </body> </html>
-
해결됨자바스크립트 알고리즘 문제풀이 입문(코딩테스트 대비)
안녕하세요 섹션8-16 수들의 조합 질문드립니다
function solution(k, nums, m) { const isMulti = (n, m) => { if (!(n % m)) return 1; return 0; }; let ans = 0; function DFS(L, sp, sum) { if (L === k) { console.log(L, tmp, sp, sum); if (isMulti(sum, m)) ans++; } else { for (let i = sp; i < nums.length; i++) { DFS(L + 1, i + 1, sum + nums[i]); } } } DFS(0, 0, 0); return ans; }해당 문제 시간복잡도가 궁금하여 질문드립니다.해당 문제를 선생님과 똑같이 풀이했는데요, DFS 내부 for문의 i시작점이 동적으로 변하다보니 시간복잡도를 어떻게 잡아야 할지 몰라 헷갈려 질문드려요.만일 for문의 i의 시작점이 고정적으로 0이라면 O(N^K)가 될 것 같은데,이처럼 i가 유동적으로 변하는 것으로 기존 빅오 표기에 영향이 갈만큼 차이가 발생하게 되나요?시간내어 확인해주셔서 감사합니다.
-
미해결타입스크립트 입문 - 기초부터 실전까지
ts2345
제가 강의를 따라하면서 코드를 아래처럼 작성했습니다interface PhoneNumberDictionary { [home: string]: { num: number; }; } interface Contact { name: string; address: string; phones: PhoneNumberDictionary; } // api // TODO: 아래 함수의 반환 타입을 지정해보세요. function fetchContacts(): Promise<Contact[]> { // TODO: 아래 변수의 타입을 지정해보세요. const contacts = [ { name: "Tony", address: "Malibu", phones: { home: { num: 11122223333, }, office: { num: 44455556666, }, }, }, { name: "Banner", address: "New York", phones: { home: { num: 77788889999, }, }, }, { name: "마동석", address: "서울시 강남구", phones: { home: { num: 213423452, }, studio: { num: 314882045, }, }, }, ]; return new Promise((resolve) => { setTimeout(() => resolve(contacts), 2000); }); } setTimeout(() => resolve(contacts), 2000); 여기서 contacts에서 에러가 나는데 Argument of type '({ name: string; address: string; phones: { home: { num: number; }; office: { num: number; }; studio?: undefined; }; } | { name: string; address: string; phones: { home: { num: number; }; office?: undefined; studio?: undefined; }; } | { ...; })[]' is not assignable to parameter of type 'Contact[] | PromiseLike<Contact[]>'. Type '({ name: string; address: string; phones: { home: { num: number; }; office: { num: number; }; studio?: undefined; }; } | { name: string; address: string; phones: { home: { num: number; }; office?: undefined; studio?: undefined; }; } | { ...; })[]' is not assignable to type 'Contact[]'. Type '{ name: string; address: string; phones: { home: { num: number; }; office: { num: number; }; studio?: undefined; }; } | { name: string; address: string; phones: { home: { num: number; }; office?: undefined; studio?: undefined; }; } | { ...; }' is not assignable to type 'Contact'. Type '{ name: string; address: string; phones: { home: { num: number; }; office: { num: number; }; studio?: undefined; }; }' is not assignable to type 'Contact'. Types of property 'phones' are incompatible. Type '{ home: { num: number; }; office: { num: number; }; studio?: undefined; }' is not assignable to type 'PhoneNumberDictionary'. Property 'studio' is incompatible with index signature. Type 'undefined' is not assignable to type '{ num: number; }'.ts(2345)라고 뜹니다 제가 잘못 따라한게 있을가요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
N:M tag 부분 구현 중 findOne 조회 부분 에러
products.service.ts에서 create 부근에 tag를 저장 하기 전 tag를 미리 조회하는 부분을 구현 중인데 findOne에서 {name: tagname} 을 구현하려고 할 때 다음과 같은 에러가 발생합니다. save에서는 에러가 발생하지 않는데 findOne 조회 부분만 에러가 발생하네요관련된 코드 같이 보내드립니다.createProduct.input.tsimport { InputType, Field, Int } from '@nestjs/graphql'; import { Min } from 'class-validator'; import { ProductSaleslocationInput } from 'src/apis/productsSaleslocation/entities/dto/productSaleslocation.input'; @InputType() export class CreateProductInput { @Field(() => String) name: string; @Field(() => String) description: string; @Min(0) @Field(() => Int) price: number; @Field(() => ProductSaleslocationInput) productSaleslocation: ProductSaleslocationInput; @Field(() => String) productCategotyId: string; @Field(() => [String]) productTags: string[]; } products.entity.tsimport { Field, Int, ObjectType } from '@nestjs/graphql'; import { ProductCategory } from 'src/apis/productsCategory/entities/productsCategory.entity'; import { ProductTag } from 'src/apis/productsTags/productTags.entity'; import { User } from 'src/apis/users/users.entity'; import { Column, DeleteDateColumn, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToOne, PrimaryGeneratedColumn, } from 'typeorm'; import { ProductSaleslocation } from '../../productsSaleslocation/entities/productsSaleslocation.entity'; @Entity() @ObjectType() export class Product { @PrimaryGeneratedColumn('uuid') @Field(() => String) id: string; @Field(() => String) @Column() name: string; @Field(() => String) @Column() description: string; @Field(() => Int) @Column() price: number; @Field(() => Boolean) @Column({ default: false }) isSoldout: boolean; @DeleteDateColumn() deletedAt: Date; @Field(() => ProductSaleslocation) @JoinColumn() @OneToOne(() => ProductSaleslocation) productSaleslocation: ProductSaleslocation; @Field(() => ProductCategory) @ManyToOne(() => ProductCategory) productCategory: ProductCategory; @Field(() => User) @ManyToOne(() => User) user: User; @JoinTable() @ManyToMany(() => ProductTag, (productTags) => productTags.products) @Field(() => [ProductTag]) productTags: ProductTag[]; } productTags.entity.tsimport { Field, ObjectType } from '@nestjs/graphql'; import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'; import { Product } from '../products/entities/products.entity'; @Entity() @ObjectType() export class ProductTag { @Field(() => String) @PrimaryGeneratedColumn('uuid') id: string; @Column() @Field(() => String) name: string; @Field(() => [Product]) @ManyToMany(() => Product, (products) => products.productTags) products: Product[]; } products.service.tsimport { Product } from './entities/products.entity'; import { Injectable, UnprocessableEntityException } from '@nestjs/common'; import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; import { ProductSaleslocation } from '../productsSaleslocation/entities/productsSaleslocation.entity'; import { ProductTag } from '../productsTags/productTags.entity'; @Injectable() export class ProductService { constructor( @InjectRepository(Product) private readonly productRepository: Repository<Product>, @InjectRepository(ProductSaleslocation) private readonly productSaleslocationRepository: Repository<ProductSaleslocation>, @InjectRepository(ProductTag) private readonly productTagRepository: Repository<ProductTag>, ) {} async findAll() { return await this.productRepository.find({ relations: ['productSaleslocation', 'productCategory', 'productTags'], }); } async findOne({ productId }) { return await this.productRepository.findOne({ where: { id: productId }, relations: ['productSaleslocation', 'productCategory', 'productTags'], }); } async create({ createProductInput }) { // 1. 상품만 등록하는 경우 // const result = await this.productRepository.save({ // ...createProductInput, // // 하나 하나 직접 나열하는 방식 // // name: createProductInput.name, // // description: createProductInput.description, // // price: createProductInput.price, // }); // 2. 상품과 상품거래 위치 같이 등록 const { productSaleslocation, productCategotyId, productTag, ...product } = createProductInput; const result = await this.productSaleslocationRepository.save({ ...productSaleslocation, }); // productTag // ["#electronics, #computer"] const result2 = []; // [{name: ..., id: ...}] for (let i = 0; i < productTags.length; i++) { const tagName = productTags[i].replace('#', ''); // check the tags that has already registered const checkTag = await this.productTagRepository.findOne({ name: tagName, }); // if the tags has been existed if (checkTag) { result2.push(checkTag); // if the tags hasn't been existed } else { const newTag = await this.productTagRepository.save({ name: tagName }); result2.push(newTag); } } const result3 = await this.productRepository.save({ ...product, productSaleslocation: result, // result 통째로 넣기 vs id만 넣기 productCategory: { id: productCategotyId }, productTags: result2, }); return result3; } async update({ productId, updateProductInput }) { const myProduct = await this.productRepository.findOne({ where: { id: productId }, }); const newProduct = { ...myProduct, id: productId, ...updateProductInput, }; return await this.productRepository.save(newProduct); } async checkSoldOut({ productId }) { const product = await this.productRepository.findOne({ where: { id: productId }, }); if (product.isSoldout) { throw new UnprocessableEntityException('Sold out'); } // if(product.isSoldout) { // throw new HttpException('이미 판매 완료 된 상품입니다.', HttpStatus.UNPROCESSABLE_ENTITY) // } } async delete({ productId }) { // 1. 실제 삭제 // const result = await this.productRepository.delete({ id: productId }); // return result.affected ? true : false // 2. 소프트 삭제(직접 구현) - isDeleted // this.productRepository.update({ id: productId }, { isDeleted: true }); // 3. 소프트 삭제(직접 구현) - deletedAt // this.productRepository.update({ id: productId }, { deletedAt: new Date() }); // 4. 소프트 삭제(TypeORM 제공) - softRemove - id로만 삭제 가능 // this.productRepository.softRemove({ id: productId }); // 4 . 소프트 삭제(TypeORM 제공) - softDelete const result = await this.productRepository.softDelete({ id: productId }); return result.affected ? true : false; } } 내용 확인 부탁드립니다.
-
해결됨[코드캠프] 시작은 프리캠프
싸이월드 만들기 1탄 padding margin 질문있습니다.
이게 background이고이게 outer입니다.이게 .background에만 padding을 준거구요.background { width: 1024px; height: 600px; background-image: url("../images/background.png"); padding: 20px 0px 0px 20px; } .outerbox { width: 808px; height: 544px; background-image: url("../images/outerbox.png"); }이게 .outerbox에만 margin을 준거에요..background { width: 1024px; height: 600px; background-image: url("../images/background.png"); } .outerbox { width: 808px; height: 544px; background-image: url("../images/outerbox.png"); margin: 20px 0px 0px 20px; }class="outerbox"가 class="background" 안에 들어가있잖아요? 그럼 .outerbox에 margin을 주면 .background는 여백이 생기면 안되잖아요. .outerbox에만 여백이 생겨야하는거 아니에요? background 위쪽은 그대로이고 outerbox만 여백이 생겨야하는거 아닌가용?이게 웃긴게 margin을 20px 0px 0px 20px줬는데 background의 왼쪽은 그대로이고 위쪽만 내려왔다는거에요.. background의 왼쪽은 여백이 안생김.. +.background { display: flex; width: 1024px; height: 600px; background-image: url("../images/background.png"); } .outerbox { width: 808px; height: 544px; background-image: url("../images/outerbox.png"); margin: 20px 0px 0px 20px; }웃긴게 background쪽에 display: flex 추가하니까 .outerbox에 margin 추가 해도 여백이 제대로 생깁니다 이건 또 뭘까요..
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
권한 요청 부탁드립니다.
인프런 아이디 : stomboy2@naver.com인프런 이메일 : stomboy2@naver.com깃헙 아이디 : tyo1012@naver.com깃헙 Username : Five-Sun
-
해결됨자바스크립트 알고리즘 문제풀이 입문(코딩테스트 대비)
안녕하세요 섹션8 DFS의 동전교환 문제 관련 질문드립니다.
function solution(coins, m) { coins.sort((a, b) => b - a); let ans = 0; function DFS(L, sum) { if (sum > m) { return; } if (sum === m) { ans = L; return "end"; } else { for (let i = 0; i < coins.length; i++) { if (DFS(L + 1, sum + coins[i]) === "end") return "end"; } } } DFS(0, 0); return ans; } 동전 교환 문제에서 강사님께서 가르쳐주신 코드도 실습해 본 후, 제 나름대로 작성해본 코드입니다. 제 얕은 생각으로는 위 코드처럼 가장 먼저 동전 종류를 내림차순으로 정렬한 후, DFS를 가지쳐 내려나간다면, 가장 큰 단위부터 적용해나가므로 맨 처음 종료조건에 도달해 ans에 대입되는 값이 무조건 최소동전 개수가 되지 않을까 생각해서 이렇게 작성했습니다.이 풀이가 틀린지 궁금하고, 만일 맞다면 시간복잡도 상 효율이 극단적으로 떨어지는 최악의 경우가 존재할 지 또한 궁금합니다.귀한 시간 내어 읽어주셔서 감사합니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
안녕하세요 질문있습니다!
@ObjectType이랑 @EntryType이랑 같이 사용을 할수는 없는건가요??dto와 entry가 다른부분이 없어서 같이 쓰는게 낫겠다싶어서 시도하려니 안되네요확실히 역할을 나눠야하는건가요??
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
reaxt router npm 설치
안녕하세요~섹션6 페이지 라우팅1-React Router기본 편 듣고 있는데강의에 나오는 React Router 사이트에 들어가면 Installation 이라는 카테고리가아에 없는데.. 혹시 2023년 3월8일 기준으로 방법이 있나요?ㅠㅠ 홈페이지 다 눌러봐도안보이네요ㅠㅠㅠ
-
미해결Vue.js 끝장내기 - 실무에 필요한 모든 것
강의 교안 혹은 노트
안녕하세요. 강의 중간 중간에 말씀하신 강의 교안 혹은 노트는 어디서 받을 수 있나요?확인 부탁드립니다.
-
미해결Vue.js 중급 강좌 - 웹앱 제작으로 배워보는 Vue.js, ES6, Vuex
i 태그 사용 시 click event 안먹는 이유
안녕하세요. 강의 들으면서 하나하나 따라했는데 i태그 사용하여 v-on:click 시, 클릭이벤트가 전혀 먹히지 않아 일단 span태그로 감싸 사용했습니다. 강사님은 i태그만 사용해도 이벤트가 적용 되는데 왜 안되는지 이유를 알 수 있을까요?제 코드는 아래에 있습니다. <template> <div> <ul> <li v-for="(todoItem, index) in todoItems" v-bind:key="todoItem.item" class="shadow" > <span v-on:click="toggleComplete(todoItem, index)"> <i class="checkBtn fas fa-check" v-bind:class="{ checkBtnCompleted: todoItem.completed }" ></i> </span> <span v-bind:class="{ textCompleted: todoItem.completed }"> {{ todoItem.item }} </span> <span class="removeBtn" v-on:click="removeTodo(todoItem, index)" > <i class="fa-regular fa-trash-can"></i> </span> </li> </ul> </div> </template> <script> export default { data: function () { return { todoItems: [], }; }, methods: { removeTodo: function (todoItem, index) { localStorage.removeItem(todoItem); this.todoItems.splice(index, 1); }, toggleComplete: function (todoItem, index) { todoItem.completed = !todoItem.completed; localStorage.removeItem(todoItem.item); localStorage.setItem(todoItem.item, JSON.stringify(todoItem)); }, }, created: function () { if (localStorage.length > 0) { for (let i = 0; i < localStorage.length; i++) { localStorage.getItem(localStorage.key(i)); this.todoItems.push( JSON.parse(localStorage.getItem(localStorage.key(i))) ); } } }, }; </script> <style scoped> ul { list-style-type: none; padding-left: 0px; margin-top: 0; text-align: left; } li { display: flex; min-height: 50px; height: 50px; line-height: 50px; margin: 0.5rem 0; padding: 0 0.9rem; background: white; border-radius: 5px; } .removeBtn { margin-left: auto; color: #de4343; } .checkBtn { line-height: 45px; color: #62acde; margin-right: 5px; } .checkBtnCompleted { color: #b3adad; } .textCompleted { text-decoration: line-through; color: #b3adad; } </style>
-
해결됨[코드캠프] 시작은 프리캠프
정렬 기능이랑 튀어나오는게 무슨 관계인가요?
이게 정렬하지 않은 block요소(div)+기본값(row)상태로 body가 아래 튀어나와있고이게 column값을 줘서 정렬된 상태로 튀어나온 부분이 사라졌습니다. div가 block요소이고 정렬이 안된 row상태이니 위처럼 튀어나오는건 이해할 수 있습니다.그런데 column을 줘서 수직으로 정렬해도 튀어나오는건 그대로여야하지 않나요? 왜 튀어나온게 들어가는거죠?
-
미해결풀스택을 위한 탄탄한 프런트엔드 부트캠프 (HTML, CSS, 바닐라 자바스크립트 + ES6) [풀스택 Part2]
자료 이메일 요청건
안녕하세요, 어제부터 본격적으로 잔재미 코딩님의 강의를 수강 중입니다.공부 중에 강의 자료가 있으면 혼자 복습하는데 좋을 것 같아서 요청드리고자 합니다. 이메일 : minhwa0819@naver.com 확인 감사합니다~