일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- 타사인증
- 북마크앱
- MyPick31
- MYSQL
- Django Blog
- 장고 개발 순서
- Blog
- python
- 장고
- 개발
- Node.js
- 파이썬 웹프로그래밍 장고
- mongodb
- JavaScript
- passport.js
- ART_Cinema
- 북마크만들기
- 독립영화플랫폼
- 자바스크립트
- 알고리즘
- Exercism
- 장고 프로젝트
- 예술영화추천
- Algorithm
- til
- Django
- 프로젝트
- join()
- Bookmark
- 장고 프로젝트 순서
- Today
- Total
Juni_Dev_log
(210123_TIL) 'Hello World', 'Two Fer' 본문
자료구조, 알고리즘 문제를 하루에 1-2개씩 풀기 위해서,
Exercism
Code Practice and Mentorship for Everyone. Level up your programming skills with 1,879 exercises across 38 languages, and insightful discussion with our dedicated team of welcoming mentors. Exercism is 100% free forever.
exercism.io
Exercism 이라는 문제은행 사이트에서 Javascript 언어로 문제 풀이를 진행했다.
처음에는 조금 쉬운 난이도인 easy 난이도의 문제 2개를 풀었다.
▶ Hello World
(Problem)
The classical introductory exercise. Just say "Hello, World!".
"Hello, World!" is the traditional first program for beginning programming in a new language or environment.
The objectives are simple:
- Write a function that returns the string "Hello, World!".
- Run the test suite and make sure that it succeeds.
- Submit your solution and check it at the website.
If everything goes well, you will be ready to fetch your first real exercise.
- 함수의 결과로 "Hello, World" 가 나오게 만드는 함수를 작성하라는 문제이다.
(Solution)
1
2
3
4
5
6
7
8
9
|
//
// This is only a SKELETON file for the 'Hello World' exercise. It's been provided as a
// convenience to get you started writing code faster.
//
export const hello = () => {
return 'Hello, World!';
};
|
cs |
화살표 함수로 작성해서 진행했다.
해당 코드는,
1
2
3
4
5
6
7
8
|
//
// This is only a SKELETON file for the 'Hello World' exercise. It's been provided as a
// convenience to get you started writing code faster.
//
function hello(){
return 'Hello, World!';
}
|
cs |
와 똑같은 코드이다.
ko.javascript.info/arrow-functions-basics
화살표 함수 기본
ko.javascript.info
▶ Two-Fer
(Problem)
Two-fer or 2-fer is short for two for one. One for you and one for me.
Given a name, return a string with the message:
One for name, one for me.
Where "name" is the given name.
However, if the name is missing, return the string:
One for you, one for me.
Here are some examples:
NameString to return
name | expression |
Alice | One for Alice, one for me. |
Bob | One for Bob, one for me. |
You | One for you, one for me. |
Zaphod | One for Zaphod, one for me. |
- 이름이 없다면, "One for name, one for me." 를 반환한다.
- 이름이 있다면, name 자리에 해당 이름이 들어가는 문자열을 반환하도록 작성한다.
(Solution)
1
2
3
4
5
6
7
8
9
|
//
// This is only a SKELETON file for the 'Two fer' exercise. It's been provided as a
// convenience to get you started writing code faster.
//
export const twoFer = (name="you") => {
return `One for ${name}, one for me.`;
};
|
cs |
- One for name, one for me. 를 고정적으로 나오도록 하고, name으로 들어가는 값이 삽입되도록 {} 문자열 리터럴을 활용했다.
1
2
3
4
5
6
7
8
|
//
// This is only a SKELETON file for the 'Two fer' exercise. It's been provided as a
// convenience to get you started writing code faster.
//
function twoFer(name="you"){
return `One for ${name}, one for me.`;
}
|
cs |
'CodingTest > Exercism' 카테고리의 다른 글
(200128_TIL) 'Bank Account' (0) | 2021.01.28 |
---|---|
(200127_TIL) 'Pangram' (0) | 2021.01.27 |
(200126_TIL) 'Space Age' (0) | 2021.01.26 |
(200125_TIL) 'Gigasecond', 'RNA Transcription' (0) | 2021.01.25 |
(200124_TIL) 'Resistor Color', 'Resistor Color Duo' (0) | 2021.01.24 |