+ 2
Someone please explain nesting codes in simple terms , i am in highschool and I know nothing about coding
3 ответов
+ 4
Nesting can go beyond two identical statements. Many concepts include nesting. Every function has statements nested inside it. Some languages allow nesting functions within one another. All loops have nested statements just like those statements nested with Jenine's ifs. These levels of nesting might provide scope of name definitions. A variable declared in a for statement exists only within that statement including those nested. Once it completes, that variable is gone.
+ 1
Hey _ clara_,
Nested means when something is inside something else of the same type.
For example an If statement is a block of code that executes based on a condition. A nested If statement would be:
if (value)
{
console.log(“In first if statement”);
if (nextValue)
{
console.log(“In nested if statement”);
}
}
The second if statement (“if(nextValue)”) is nested because it is already within another if statement
If you feel like you know nothing about coding, have a go at some of the language tutorials and it will introduce you to if statements and more. All the best with school!
0
Nesting is used when you have to get put your output combining two or more loging.
For example:
If(name=="ishan")
{
Console.log("my name is ishan")
If(lastname=="shah")
{
Console.log("my name is ishan shah")
}
}