Goal: In the last lesson, we learned:
forloop both with and without arrays
Practice utilizing for loops in a variety of ways by completing the exercises detailed below.
Array.prototype.forEach()loops? Why should you generally favor
forloop and what is it for?
Create a program that takes two numbers - one to count to and another to determine what multiple to use to get there.
Here is some sample input:
Count to: 30
Count by: 5
Output: 5, 10, 15, 20, 25, 30
Count to: 50
Count by: 7
Output: 7, 14, 21, 28, 35, 42, 49
Don't forget to consider how to handle any input that might be submitted:
Go back through the looping practice problems, and redo one of them with a
for loop instead of a
Create a website that uses a method to replace vowels in a string with the dash symbol "-" to create a word puzzle to solve. Hide the original string when you show the resulting word puzzle, so that another person can try and guess it.
String Input: "Believe you can and you're halfway there. Theodore Roosevelt"
Puzzle Output: "B-l--v- y-- c-n -nd y--'r- h-lfw-y th-r-. Th--d-r- R--s-v-lt"
Do this without regular expressions. (If you don't know what a regular expression is yet, don't worry - we will be covering them in a future lesson.)
forEach()loops being used correctly?
Lesson 18 of 34
Last updated September 2, 2020