Creating a if statement inside an if statement in a Javascript function node

Hey guys, currently i have some problems with not knowing how to create a if satement inside a if statement in a Javascript function node, currently last piece i need to do for my project to work. How do i do this? Is it even possible?

Have you looked at examples?
nested examples

[edit] fixed wrong link

I have not. I will thank you!

Actually that example page is for Go rather than Javascript, though the principle is the same

if (A) {
  ...
  if (B) {
    ...
  }
  ...
}
1 Like

Indeed it is the same principle.

Internet search should always be the first port of call:

Yes, it is indeed possible to nest if statements within other if statements in JavaScript functions. This technique is commonly used to create more complex conditional logic. Here's a basic example:

function myFunction(condition1, condition2) {
if (condition1) {
// Executed if condition1 is true
if (condition2) {
// Executed if both condition1 and condition2 are true
console.log("Both conditions are true.");
} else {
// Executed if condition1 is true but condition2 is false
console.log("Condition1 is true, but Condition2 is false.");
}
} else {
// Executed if condition1 is false
console.log("Condition1 is false.");
}
}
In this example, we have a function myFunction that takes two conditions as parameters. Inside the function, we have nested if statements to handle different scenarios based on the conditions provided. Depending on the values of condition1 and condition2, different blocks of code will be executed.