Chapter [ ๋ฐ˜๋ณต๋ฌธ ]

๋ฐ˜๋ณต๋ฌธ์ด๋ž€?

๊ฐ™๊ฑฐ๋‚˜ ๋น„์Šทํ•œ ์ฝ”๋“œ๋ฅผ ์—ฌ๋Ÿฌ ๋ฒˆ ์‹คํ–‰์‹œ์ผœ์•ผ ํ•  ๊ฒฝ์šฐ์— ์“ฐ๋Š” ๊ตฌ๋ฌธ

  • For ๋ฌธ
 [ for( ์ดˆ๊ธฐํ™” ; ์กฐ๊ฑด์‹ ; ์ฆ๊ฐ๋ฌธ ){ ๋ฐ˜๋ณตํ•  ๋‚ด์šฉ } ]

  let sum=1;
  for(let n=2; n<=4; n=n+1;){
    sum=sum+n;
  } //5
  • While ๋ฌธ

 [ ์ดˆ๊ธฐํ™” while( ์กฐ๊ฑด์‹ ){ ๋ฐ˜๋ณตํ•  ๋‚ด์šฉ; ์ฆ๊ฐ๋ฌธ } ]

  let sum=1;
  let n=2;
  while(n<=4){
    sum=sum+n;
    n=n+1;
  } //5

  let sum=1;
  let n=2;
  while(n<=4){
    n=n+1;
    sum=sum+n;
  } //13
  • break ๋ฌธ

    if,switch,for,while๋ฌธ๋“ฑ์—์„œ break๋ฌธ์„ ๋งŒ๋‚˜๋ฉด ๋ฐ”๋กœ ๋น ์ ธ๋‚˜๊ฐ€๋Š” ๋ช…๋ น๋ฌธ

  • continue ๋ฌธ

    ์–ด๋– ํ•œ ํ–‰์œ„๋ฅผ ํ•˜๋‹ค๊ฐ€ continue๋ฌธ์„ ๋งŒ๋‚˜๋ฉด ํ•ด์•ผํ•  ๋ช…๋ น๋ฌธ์„ ์‹คํ–‰ํ•˜์ง€ ์•Š๊ณ  ๊ทธ ๋‹ค์Œ ๋ช…๋ น๋ฌธ์„ ์‹คํ–‰ํ•˜๋Š” ๋ช…๋ น๋ฌธ

  • return ๋ฌธ

    ํ•จ์ˆ˜ ์•ˆ์—์„œ ๋ช…๋ น๋ฌธ๋“ค์„ ์‹คํ–‰ํ•˜๋‹ค๊ฐ€ return์„ ๋งŒ๋‚˜๋ฉด ํ•จ์ˆ˜๋ฅผ ๋น ์ ธ๋‚˜๊ฐ€๋Š” ๋ช…๋ น๋ฌธ


์ œ์ผ ์–ด๋ ค์šด ๋ถ€๋ถ„์ด์—ˆ๋‹ค..

์ฝ”ํ’€๋ฆฟ ๋ฌธ์ œ๋“ค์„ ๋ฐ˜๋ณต์ ์œผ๋กœ ํ’€์–ด๋ณด๋ฉด์„œ

๋ฐ˜๋ณต๋ฌธ์— ๋Œ€ํ•œ ์ดํ•ด๋ฅผ ๋จผ์ € ํ•ด๋ณด์ž ๐Ÿ‘Š๐Ÿป

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ