Yahoo Poland Wyszukiwanie w Internecie

Search results

  1. Write a JS code to print Even numbers in given array. Function `printEven ()` prints all the even numbers of a 2D array using for loops and ‘%’ operator. function printEven(arr) { for (var i=0;i<arr.length;i++){ if(arr[i]%2==0){ console.log(arr[i]); //print even number. } . } } var arr = [13,23,12,45,22,48,66,100]

  2. 19 lip 2024 · The exercises we will cover include: Printing Numbers from 1 to 10 using While Loop in JavaScript. Summing the First N Natural Numbers with JavaScript While Loop. Calculating...

  3. Here are some examples of while loop in JavaScript. Example 1: var count = 0; while (count < 5) { // Condition console.log (count); count++; // updating variable i } Try It. Run Here. Code Explanation: First, the variable count is initialized to 0. Then, before entering the loop condition is checked.

  4. The JavaScript while and do…while loops repeatedly execute a block of code as long as a specified condition is true. In this tutorial, you will learn about the JavaScript while and do…while loops with examples.

  5. JavaScript while loop example. The following example uses the while statement to output the odd numbers between 1 and 10 to the console: let count = 1; while (count < 10) {. console.log(count); count += 2; } Code language: JavaScript (javascript) Output: 1.

  6. The example below uses a do while loop. The loop will always be executed at least once, even if the condition is false, because the code block is executed before the condition is tested: Example. do { text += "The number is " + i; i++; } while (i < 10); Try it Yourself »

  7. With a while loop, you can execute code repeatably as long as a certain condition is fulfilled. It is written with the while keyword followed by a condition wrapped in round brackets and a code block that contains the body of the loop wrapped in curly brackets.

  1. Ludzie szukają również