👽
frontend-survival
  • Dev Note
    • 🐣1주차
      • 개발환경
      • TypeScript
      • React
      • Testing Library
      • Parcel & ESlint
    • 🐥2주차
      • JSX
      • Virtual DOM
    • 🐥3주차
      • React Component
      • React State
    • 🐥4주차
      • Express
      • fetch API & CORS
      • React Hooks
      • useRef & custom hook
      • usehooks-ts
    • 🐥5주차
      • TDD
      • React Testing Library
      • MSW
    • 🐥6주차
      • external store
      • tsyringe
    • 🐥7주차
      • routing
      • routes
      • router
      • navigation
    • 🐥8주차
      • design system
      • style basics
      • styled components
    • 🐥javascript
      • promise
    • 🐥practice
      • 240102
      • 240103
      • 240423
      • 240424
      • 240426
      • 240430
      • 240501
      • 240506
      • 240508
      • 240512
      • 240514
      • 240515
      • 240714
      • 240716
      • 240717
      • 240808
      • 240813
      • 240816
      • 240819
      • 240820
      • 240826
      • 240904
      • 240906
      • 240909
      • 241021
    • 🐥react
      • state
      • global state
      • Context
      • module state
    • 🐥Next.js
      • app router
    • 🐥algorithm
      • reverse string
      • palindrome
      • reverse int
      • max char
      • chunk
      • anagrams
      • capitalize
      • printing step
      • pyramids
      • vowels
      • matrix spiral
      • queue from stack
    • 🐥css
      • mobile inner height
    • 🐥Clean Architecture
      • object oriented programming
Powered by GitBook
On this page
  1. Dev Note
  2. 🐥practice

240820

문제 : 시저 암호 난이도 : Lv.1

풀이

   function solution(s, n) {
    
     return s.split('').map(char => {
        // 대문자 처리
        if (char >= 'A' && char <= 'Z') {
            return String.fromCharCode((char.charCodeAt(0) - 'A'.charCodeAt(0) + n) % 26 + 'A'.charCodeAt(0));
        }
        // 소문자 처리
        else if (char >= 'a' && char <= 'z') {
            return String.fromCharCode((char.charCodeAt(0) - 'a'.charCodeAt(0) + n) % 26 + 'a'.charCodeAt(0));
        }
        // 공백은 그대로 반환
        else {
            return char;
        }
    }).join('');
    
}
Previous240819Next240826

Last updated 10 months ago