Loops and Iterations
10 JavaScript loops and iterations challenges, each with test cases you can run in the browser.
- count9 — Easy. Given an array of integers, count how many times the number 9 appears in the array.
- countOccurrences — Easy. Given a string and a character, count how many times the character appears in the string.
- sumArray — Easy. Given an array of numbers, return the sum of all the numbers in the array. Use a loop for this task.
- generateRange — Easy. Write a function that generates an array containing all integers in a specified range (inclusive).
- vowelCount — Easy. Write a function that takes a string and returns the number of vowels it contains. Vowels are 'a', 'e', 'i', 'o', 'u', and should be counted
- findFirstIndex — Easy. Given an array and a target element, return the index of the first occurrence of the target element. If the element is not found, return -1.
- doubleArrayValues — Easy. Given an array of numbers, create and return a new array where each value is doubled.
- sumOfMultiples — Easy. Find the sum of all the multiples of 3 or 5 below a given number. For example, if the number is 10, the multiples are 3, 5, 6 and 9. The sum
- countdownString — Easy. Given a positive integer, create a string that counts down from that number to 1, with each number separated by a space. For example, countd
- stringPyramid — Medium. Create a function that returns a pyramid-like string of a given height. Each level of the pyramid should be centered and made of '#' charact