do-while

차노·2023년 8월 15일
0

JS

목록 보기
43/96

A 'do-while' loop is a control flow structure found in many programming languages.

do-while문은 많은 프로그래밍 언어에서 만들어진 제어 흐름 구조이다.

It's used to executed a block of code repeatedly as long as a specified condition remains true.

특정 조건이 트루이면, 코드의 블록을 반복적으로 실행한다.

Unlike the 'while' loop, which checks the condition before entering the loop, the 'do-while' loop executes the code block at least once before evaluating the condition.

반복에 들어가기 전에 조건을 확인하는 while loop와 다르게, 'do-while' loop는 조건을 판단하기 전에 최소 한 번은 코드 구문을 실행한다.

syntax

do {
// Code to be executed
} while (condition)

  1. The code within the 'do' block is executed first, regardless of the condition. > 조건에 상관없이 do 블록 내에서 코드가 처음 실행된다.

  2. After executing the code block, the loop checks the specified condition inside the 'while' parentheses.

    코드를 실행하고 나서, 반복문은 while 괄호 안에서 특정 조건을 확인한다.

  3. If the condition evaluates to 'true', the loop continues to execute the code block again.

    트루일 경우, loop는 코드를 다시 실행한다.

If the condition evaluates to 'false', the loop terminates, and the program continues with the next statement after the loop.

트루가 아닌 경우, 루프는 그 다음 문장을 실행한다.

The main characteristic of the 'do-while' loop is that it guarantees the code block will execute at least once, since the condition is checked after the first execution.

'do-while'문의 가장 큰 특징은 첫 번째 구문을 실행하고 나서 조건을 확인한 이후에, 적어도 한 번 코드를 실행하는 것을 보증한다.

This script was brought back from chat Gpt.

0개의 댓글