![]() We'll also keep in mind that there are several types of loops, each of which performs a specific function even though they can almost all perform the same common function. In this article, we will learn what for loops are, how they work, and why we use them. This is the simplest JavaScript code, which shows the demo of how the simplest JavaScript code is created in each and every article for beginner learners.Loops are a programming concept that we constantly encounter and implement as JavaScript developers.Īnd many developers are familiar with loops, but not everyone understands how they work and why or when they should use a specific type of loop. Note: I'm using the "document.write()" method only for the example purpose, but you can choose the console.log() method to see the "num is not less than 10" to the document.ĭue to the fact that "num" in this example has a value of 12, which is greater than 10, the "else" block will be executed, and the program's output will read The program will run the statement contained in the "else" block if the value of "num" is greater than 10, in which case it will use the "document.write()" method to write ![]() Method, if the value of "num" is less than 10. The program will run the statement inside the "if" block, which in this case is to write "num is less than 10" to the document using the document.write() Than 10 or not using an if-else statement. It then checks to see if the value of the variable "num" is less The provided code creates a "num" variable and gives it the value of 12. Document.write(num + " is less than 10") Įlse document.write(num + " is not less than 10")
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |