목록IT (17)
BugDIARY
# 배열 중복 제거하기 def solution(arr): answer = [] # 배열 길이 만큼 for문을 실행 for n in range(len(arr)-1): # 배열의 앞 뒤를 비교하여 앞뒤가 다를 경우 answer배열에 값을 저장 if arr[n] != arr[n+1]: answer.append(arr[n]) # for문을 종료 후 arr의 제일 마지막 값도 append해줌. # 이유는 서로 앞 뒤를 비교할 경우 제일 마지막 값은 서로 다르더라도 저장되지 않기 때문. # 목적은 중복 제거이기 때문에, (1, 1, 2, 2)의 경우 마지막의 2, 2를 비교했을 때 2라는 값을 추가해야 하는데 # 위의 if문 대로라면 앞의 값이 뒤에 값과 같아 저장되지 않기 때문에(2 != 2 가 False이기 때..
[문제] 다음은 숫자의 일부 자릿수를 영단어로 바꾸는 예시입니다. 1478 → "one4seveneight" 234567 → "23four5six7" 10203 → "1zerotwozero3" 이렇게 숫자의 일부 자릿수가 영단어로 바뀌어졌거나, 혹은 바뀌지 않고 그대로인 문자열 s가 매개변수로 주어집니다. s가 의미하는 원래 숫자를 return 하도록 solution 함수를 완성해주세요. 참고로 각 숫자에 대응되는 영단어는 다음 표와 같습니다. 숫자 영단어 0 zero 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eight 9 nine 제한사항 1 ≤ s의 길이 ≤ 50 s가 "zero" 또는 "0"으로 시작하는 경우는 주어지지 않습니다. return 값이 1..
spring에러 때 확인한 페이지 web.xml에러의 경우 출처 : https://www.programmersought.com/article/40922001615/ web.xml file error: Referenced file contains errors, cvc-id.3: A field of identity constraint - Programmer Sought web.xml file error: Referenced file contains errors, cvc-id.3: A field of identity constraint tags: web project Profiles Introduction: import maven project, web.xml reported three errors! Erro..
▶import 특정 기능이나 파일, 변수 등 export된 것의 기능을 사용하고 싶은 경우 import를 사용합니다. ▶export 특정 기능을 export하여 다른 곳에서 사용할 수 있게 합니다. 크게 두 가지 방법으로 사용할 수 있습니다. app.js export default app; - app파일 전체를 export합니다. init.js import app from "./app.js"; - init파일에서 export한 app파일을 불러와 app파일 안의 변수 및 함수를 사용합니다. router.js export const userRouter = express.Router(); userRouter.get("/", (req, res) => res.send('home index')); userRout..
▶Middleware사용하기 middleware는 요청과 서버 사이에서 실행하는 것을 말합니다. 미들웨어는 변수로서 request, response, next를 받을 수 있습니다. (가지고 있음) const middlewareHome = (req, res, next) => { console.log("middleWare View"); next(); } app.get("/", middlewareHome, handleHome); 간단히 Middleware를 확인할 수 있는 함수입니다. ① middlewareHome이라는 함수는 request, response, next라는 변수를 가지고 있으며 ② 이 변수에 값을 받게 되면 안의 console.log를 실행한 뒤 ③ next()를 반환시켜줍니다. ※ 현재의 미..
babel이란 대상 환경에 필요한 구문 변환 (및 선택적으로 브라우저)를 세부적으로 관리 할 필요없이 최신 JavaScript를 사용할 수있는 스마트 사전 설정입니다. babel을 설치함으로서 최신 JS코드를 작성할 수 있게 됩니다. 지금은 node에서 사용하는 babel을 설치하여야 하므로 아래와 같이 입력합니다. ▶ 설치 방법 npm install @babel/node PS [대상 프로젝트]> npm install babel npm WARN deprecated babel@6.23.0: In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the..
○ Express를 설치하고 싶은 폴더 안에서 아래와 같은 커맨드 입력 npm install express PS [프로젝트경로]> npm install express npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN enoent ENOENT: no such file or directory, open '[프로젝트경로]\package.json' npm WARN PublicRecipe No description npm WARN PublicRecipe No repository field. npm WARN PublicRecipe No README data npm WARN PublicRecipe No li..
app.js import "core-js"; import express from "express"; import morgan from "morgan"; import helmet from "helmet"; import cookieParser from "cookie-parser"; import bodyParser from "body-parser"; const app = express(); app.use(cookieParser()); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: true})); app.use(helmet()); app.use(morgan("dev")); export default app; - nodejs의 경우, e..