[TIL] more about JS

Soo·2022년 11월 12일
0
post-thumbnail

We are working with Visual Studio Code(VS Code) and Node.js for pre-onboarding week.

Things I keep making mistakes and things that make sure while using these:

  • SAVE THE CODE (command + s)
  • command 'node somthing(file).js' which means to run something.js file.

Things that I need to make sure:

  • The difference btw Prefix and Postfix

  • The For loop
    Loops are kind of handy, if you want to run the same code over and over again, each time with a different value.
for (expression(1); expression(2); expression(3)) {
 // code block to be executed
}

First, you can divide this part into 3 parts as below:

  • Expression(1) is executed (one time) before the execution of the code block.

  • Expression(2) defines the condition for executing the code block.

  • Expression(3) is executed (every time) after the code block has been executed.

for (let i = 0; i < 5; i++) {
  console.log(`${i}번째 반복입니다.`)
}

From the example above, you can read:

Expression(1) sets a let before the loop starts (let i = 0).

Expression(2) defines the condition for the loop to run (i must be less than 5).

Expression(3) increases a value (i++) each time the code block in the loop has been executed.

profile
Soogineer's Devlog

0개의 댓글