Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. 1 maj 2024 · The while statement creates a loop that executes a specified statement as long as the test condition evaluates to true. The condition is evaluated before executing the statement. Try it. Syntax. js. while (condition) . statement. condition. An expression evaluated before each pass through the loop.

  2. 7 wrz 2024 · The basic tool for looping through a collection is the for...of loop: js. const cats = ["Leopard", "Serval", "Jaguar", "Tiger", "Caracal", "Lion"]; for (const cat of cats) { console.log (cat); } In this example, for (const cat of cats) says: Given the collection cats, get the first item in the collection.

  3. Syntax. while (condition) { // code block to be executed. } Example. In the following example, the code in the loop will run, over and over again, as long as a variable (i) is less than 10: Example. while (i < 10) { text += "The number is " + i; i++; } Try it Yourself »

  4. Python while Loop. In Python, we use a while loop to repeat a block of code until a certain condition is met. For example, number = 1 while number <= 3: print (number) number = number + 1. Output. 1 2 3. In the above example, we have used a while loop to print the numbers from 1 to 3.

  5. 19 cze 2022 · The while loop has the following syntax: while (condition) { // code // so-called "loop body" } While the condition is truthy, the code from the loop body is executed. For instance, the loop below outputs i while i < 3: let i = 0; while (i < 3) { // shows 0, then 1, then 2 alert ( i ); i++; }

  6. The while Loop. With the while loop we can execute a set of statements as long as a condition is true.

  7. JavaScript while Loop. The most basic loop in JavaScript is the while loop which would be discussed in this chapter. The while loop is an entry-controlled loop. The purpose of a while loop is to execute a statement or code block repeatedly as long as an expression is true.

  1. Ludzie szukają również