본문 바로가기

전체 글

(68)
완전탐색 모의고사 수포자 / '%'를 쓸줄아느냐. 내 접근 방식 사람마다 규칙에 따라 답이 반복되는데 이걸 계산식으로 표현할수 있나...? 어떻게 하지..? 생각이 안났다. 그래서 정답 리스트를 만들어버렸다. while (per3.length < answers.length) { per3.concat(per3); } 이렇게하면 정답 길이근처만큼 개인의 답이 확장되겠지? but 너무 메모리를 크게 사용한다. 이 문제의 핵심은 "%" 나머지 기호를 잘 쓸줄 아느냐. function solution(answers) { var answer = []; const man1 = [1, 2, 3, 4, 5]; const man2 = [2, 1, 2, 3, 2, 4, 2, 5]; const man3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; let co..
완주하지 못한 선수. 나의 풀이 function solution(participant, completion) { var answer = ''; participant.sort(); completion.sort(); for (var i= 0; i < participant.length; i++) { if (participant[i] === completion[i]){ } else { answer = participant[i]; return answer; } } return answer; } 떠오른 생각_ 1. 두 리스트 participant와 completion을 오름차순이든 내림차순이든 같은 방식으로 정렬한다. 2. loop를 돌려 같은 번째 인덱스끼리 비교한다. 3. 같은 인덱스끼리 비교했을 때 같은 값이 나오지 않으면 그 인..
MongoDB 연결하기 1. 나의 mongoDB URI를 가져와서 config에 붙여줍니다 MONGO_URI=mongodb+srv://moonq:@cluster0-t1ik2.mongodb.net/cluster0?retryWrites=true&w=majority 2. mongoose를 설정합니다~ const mongoose = require('mongoose'); const connectDB = async () => { try { const conn = await mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true, useCreateIndex: true, userUnifiedTopology: true }); console.log(`MongoDb Connected: $..
회원 가입 1. User 모델 생성 const mongoose = require('mongoose'); const UserSchema = new mongoose.Schema({ name: { type: String, required: true }, email: { type: String, required: true, unique: true }, password: { type: String, required: true }, date: { type: Date, default: Date.now } }); module.exports = User = mongoose.model('user', UserSchema); 2.필수적인 데이터 조건에 맞게 들어왔는지 확인. [check('name', 'Name is required')..
express api 분석 1."dependencies" 코드 출처는 여기. https://github.com/bradtraversy/devconnector_2.0 시작은 dependencies부터. { "name": "devconnector", "version": "1.0.0", "description": "Social network for developers", "main": "server.js", "scripts": { "start": "node server", "server": "nodemon server", "client": "npm start --prefix client", "dev": "concurrently \"npm run server\" \"npm run client\"", "heroku-postbuild": "NPM_CONFIG_PRODUC..
Thinkster node.js API 강의 후기. https://thinkster.io/topics/node Node.js Tutorials and Courses - Thinkster The best place on the web for tutorials and screencasts covering AngularJS, Ionic, Swift, MEAN, and more! thinkster.io 튜토리얼 괜찮은 걸 찾다가 발견했다. medium 클론 강의. 프론트단, 백단에 여러가지 있고 각각의 프레임워크들이 구현하는 것은 똑같은 medium 클론 사이트였다. 이 강의 사이트의 시작은 "똑같은 것을 여러가지 언어로 구현해 놓으면 새로운 언어를 배우기가 쉽지 않을까?" 라는 생각이라고 한다. 이게 내 맘에 들었고 가격도 한달에 30달러여서 바로 결제했다. ..
수료. https://thinkster.io/tutorials/node-json-api Building a Production Ready Node.js JSON API - Thinkster thinkster.io express로 medium 클론 사이트 만들기. (2020.4.25~2020.05.01)
Middleware _express docs Middleware : request-response 주기 안에서 request 객체, response 객체, 그리고 next 함수에 접근할 수 있는 권한을 가진 함수를 의미합니다. 그리고 next 함수는 지금의 미들웨어 함수가 성공하면 실행될 힘수를 뜻합니다. Middleware 함수는 아래의 목록의 일을 할수 있습니다. - Excute any code 모든 코드를 실행 - Make changes to the request and the response object 요청 및 응답 오브젝트에 대한 변경을 실행 - End the request-response cycle. 요청-응답 주기를 종료. - Call the next middleware in the stack 스택 내의 다음 미들웨어를 호출. var..