Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2-honggukang0623 #7

Merged
merged 2 commits into from
Apr 3, 2024
Merged

2-honggukang0623 #7

merged 2 commits into from
Apr 3, 2024

Conversation

Ghdrn1399
Copy link
Contributor

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

https://school.programmers.co.kr/learn/courses/30/lessons/120809

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

15๋ถ„ + @

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

๋ฌธ์ œ์š”์•ฝ
js๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋ฐฐ์—ด์˜ ๊ธฐ์กด๊ฐ’์— ๋‘๋ฐฐ์”ฉ ๊ณฑํ•ด์ฃผ๊ธฐ

๋ฐฐ์—ด์˜ ๊ฐ’์— 2๋ฐฐ์”ฉ ๊ณฑํ•ด ์ค„ ๋•Œ ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ

function solution(numbers) {
    var answer = [];
    
    answer.push(numbers[0] * 2);
    answer.push(numbers[1] * 2);
    answer.push(numbers[2] * 2);
    answer.push(numbers[3] * 2);
    answer.push(numbers[4] * 2);
    return answer;
}

์œ„ ์ฝ”๋“œ์ฒ˜๋Ÿผ ์ƒ๋‹นํžˆ ๊ธธ๊ณ  ๋น„ํšจ์œจ์ ์ธ ์ฝ”๋“œ๊ฐ€ ์งœ์—ฌ์ง‘๋‹ˆ๋‹ค.

๋ฐ˜๋ณต๋ฌธ while์„ ์‚ฌ์šฉํ•œ ๊ฒฝ์šฐ

let cnt = 0;
    while(cnt < numbers.length){
        answer.push(numbers[cnt]*2);
        cnt = cnt +1;
    }

์ด์ฒ˜๋Ÿผ ๋ฐ˜๋ณต๋˜๋Š” ์ฝ”๋“œ๊ฐ€ ์ค„์–ด๋“ค๋ฉด์„œ ๊ฐ„ํŽธํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ตœ์ข…์ฝ”๋“œ

function solution(numbers) {
    var answer = [];
    
    
    let cnt = 0;
    while(cnt < numbers.length){
        answer.push(numbers[cnt]*2);
        cnt = cnt +1;
    }
    return answer;
} 

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

์ง€๋‚œ ์ฃผ์ฐจ์—๋Š” js๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๊ฐ„๋‹จํ•œ ์‚ฌ์น™์—ฐ์‚ฐ์„ ์‚ฌ์šฉ ํ•ด ๋ณด์•˜๋Š”๋ฐ, ์ด๋ฒˆ์‹œ๊ฐ„์—๋Š” ๋ฐ˜๋ณต๋ฌธ ์ค‘ ํ•˜๋‚˜์ธ while๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ธฐ์กด ๋ฐฐ์—ด์˜ ๊ฐ’์— 2๋ฐฐ์”ฉ ๊ณฑํ•˜๋Š” ๋ฌธ์ œ๋ฅผ ํ’€์–ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์•„์ง ๋ฌธ๋ฒ•์ด ์ƒ์†Œํ•˜์ง€๋งŒ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋ฉด์„œ ์ ์ฐจ ์‹ค๋ ฅ์„ ๋Š˜๋ ค์•ผ๊ฒ ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฒฝ์šฐ๋ฅผ ๋‚˜๋ˆ ์„œ ์ •๋ฆฌํ•˜๋‹ˆ ๋‘ ์ฝ”๋“œ์˜ ์ฐจ์ด๊ฐ€ ์ž˜ ๋ณด์ด๋„ค์š”๐Ÿ‘๐Ÿ‘
๊น”๋”ํ•˜๊ฒŒ ์ž˜ ์งœ์‹  ๊ฒƒ ๊ฐ™์•„์š”!!

๋ฐ˜๋ณต ํšŸ์ˆ˜๊ฐ€ ์ •ํ•ด์ ธ์žˆ๋Š” ๊ฒฝ์šฐ์—” for๋ฌธ์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ€๋…์„ฑ์ด ๋” ์ข‹์„ ๊ฒƒ ๊ฐ™์•„์š”!!

for (let cnt = 0; cnt < numbers.length; cnt++) {
        answer.push(numbers[cnt] * 2);
    }

@oesnuj oesnuj closed this Apr 1, 2024
@oesnuj oesnuj reopened this Apr 1, 2024
Copy link
Collaborator

@suhyun113 suhyun113 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

js์–ธ์–ด๊ฐ€ ์ƒ์†Œํ•˜๊ธด ํ•˜์ง€๋งŒ, ์ €๋ฒˆ PR์„ ํ†ตํ•ด ํ•œ ๋ฒˆ ๋ดค๋˜ ์–ธ์–ด๋ผ ๊ทธ๋Ÿฐ์ง€ ์ดํ•ดํ•˜๊ธฐ ์ข€ ๋” ์ˆ˜์›”ํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ์‰ฝ๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ๋Š” ์ฝ”๋“œ์˜ ์˜ˆ์‹œ๋ฅผ ๋ณด์—ฌ์ฃผ๋ฉด์„œ ๋” ํšจ์œจ์ ์ธ ์ฝ”๋“œ๋ฅผ ์•Œ๋ ค์ฃผ์…”์„œ ๋น„๊ตํ•˜๋ฉด์„œ ๋ณผ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ตœ์ข…์ฝ”๋“œ๋Š” ๋ฐ˜๋ณต๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ›จ์”ฌ ๊ฐ„๊ฒฐํ•˜๊ณ  ์ข‹์€ ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์ฃผ์…”์„œ ๋ณด๊ธฐ ์ข‹์•˜์Šต๋‹ˆ๋‹ค.

js์—์„œ ๋ฐฐ์—ด์— ์ƒˆ๋กœ์šด ๊ฐ’์„ ์ถ”๊ฐ€ํ•  ๋•Œ๋Š” push๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋Š” ๊ฒƒ๋„ ์•Œ๊ฒŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ์กด์— ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋˜ ์–ธ์–ด์™€๋Š” ์‚ด์ง ๋‹ฌ๋ž๊ธฐ ๋•Œ๋ฌธ์— ์‹ ๊ธฐํ•˜๊ธฐ๋„ ํ–ˆ๊ณ , ์ƒˆ๋กœ์šด ๋‚ด์šฉ์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ์–ด ์œ ์ตํ–ˆ์Šต๋‹ˆ๋‹ค!
PR ์ž‘์„ฑํ•˜์‹ ๋‹ค๊ณ  ๊ณ ์ƒํ•˜์…จ์–ด์š”.

Copy link
Collaborator

@pu2rile pu2rile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while๋ฌธ ์‚ฌ์šฉ์— ๋Œ€ํ•ด ๋ง์”€๋“œ๋ฆฌ๋ ค ํ–ˆ๋Š”๋ฐ ์ค€์„œ ๋‹˜์ด ๋จผ์ € ๋ง์”€ํ•ด ์ฃผ์…จ๋„ค์š”!!
๋‹ค์Œ PR์—์„œ๋Š” ๋” ํšจ์œจ์ ์ธ ์ฝ”๋“œ๋กœ ๋งŒ๋‚˜๋ด์šง!
์ฝ”๋“œ ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค ํŒŒ์ดํŒ…!

@Ghdrn1399 Ghdrn1399 merged commit 278c474 into main Apr 3, 2024
1 check passed
@Ghdrn1399 Ghdrn1399 deleted the 2-honggukang0623 branch April 3, 2024 02:57
@Ghdrn1399 Ghdrn1399 restored the 2-honggukang0623 branch April 5, 2024 14:37
@oesnuj oesnuj deleted the 2-honggukang0623 branch September 13, 2024 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants