About 9,370 results
Open links in new tab
  1. Get loop counter/index using for…of syntax in JavaScript

    I understand that the basic for...of syntax in JavaScript looks like this: for (let obj of myArray) { // ... } But how do I get the loop counter/index when iterating with this syntax?

    Missing:

    • Algo

    Must include:

  2. javascript - Using a 'for' loop to count how many times a specific ...

    If you want to count the number of times a value appears in the array, you firstly need to initialise a variable outside of the loop (if you initialise in the loop, the value will be reset on each …

    Missing:

    • Algo

    Must include:

  3. how can i use a for loop to count to and count by a number in javascript?

    Aug 3, 2020 · Use modulus operator in your loop with a conditional that checks if the modulus of the number iterated is equal to zero... Count to: 30 Count by: 5 Output: 5, 10, 15, 20, 25, 30

  4. for...of - JavaScript | MDN

    Apr 10, 2025 · The for...in statement iterates over the enumerable string properties of an object, while the for...of statement iterates over values that the iterable object defines to be iterated …

  5. Count Number of Element Occurrences in JavaScript Array

    May 23, 2022 · In this guide, you'll learn how to count the number of single element occurrences as well as all element occurrences in a JavaScript array, using `for-of`, `forEach ()`, `for`, …

    Missing:

    • Algo

    Must include:

  6. JavaScript Program to Count the Occurrences of Each Character

    Nov 23, 2024 · This approach uses forEach () to loop through characters and count their occurrences in an object. It’s a modern and slightly more readable version of the for...of loop.

  7. JavaScript For Of - W3Schools

    The JavaScript for of statement loops through the values of an iterable object. It lets you loop over iterable data structures such as Arrays, Strings, Maps, NodeLists, and more:

  8. How can I use for loop to count numbers? - Stack Overflow

    Nov 26, 2015 · function countUp(start) { // a temporary array to store your numbers var tmpArr = []; for (var i = start; i < start + 10; i++) { // store the count into the array tmpArr.push(i); } // …

    Missing:

    • Algo

    Must include:

  9. Get Loop Counter/Index Using for…of Syntax in JavaScript

    The for...of loop is a very handy way to iterate through arrays and other iterable objects in modern JavaScript. But unlike a regular for loop, for...of doesn‘t give you direct access to the loop …

  10. Count Occurrences of each Element in Array in JavaScript

    Mar 2, 2024 · To count the occurrences of each element in an array: Declare a variable that stores an empty object. Use the for...of loop to iterate over the array. On each iteration, …

  11. Some results have been removed
Refresh