Write the contents of the JavaScript if statement

Asked 2 years ago, Updated 2 years ago, 45 views

vara=1;
varb = 2;
if(a< b) {//a<b>Run the contents
  a = b;
}

It was written like this, but if(a< b) If it's {//a<b, where should I write the contents of Run ?

javascript

2022-09-30 21:32

1 Answers

In this program, the a=b; line of a<b Run Content

If statement is followed by a parenthesis {}, but if a<b is true, then the parenthesis is executed.

For example, a=b; substituting b for a, and console.log("executed!) outputting what has been done."); If you want to run , you can write as follows:

 if (a< b) {
  a = b;
  console.log("executed!");
}


2022-09-30 21:32

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.