Iteration Homework
Homework Assignment: for Loop Challenge
Task: Create a program that does the following:
- Fix and improve a loop example shown in class
- Include at least two different loop conditions
- Code has to run without any error
- Must be submitted before next class using this Slack link using .ipybn format
Here is an example of one of the loops that was went over in class:
Code Runner Challenge
Create a loop
View IPYNB Source
%%js
// CODE_RUNNER: Create a loop
// Add your favorite fruits to the list
let fruits = ["Heart Shaped Herb", "Yami Yami no Mi", "Gomu Gomu no Mi"];
// this function prints the fruit list just as it is
for (let i = 0; i < fruits.length; i++) {
console.log(fruits[i]);
}
for (let x = fruits.length - 1; x >= 0; x--) {
console.log(fruits[x]);
// ^ I'm reversing the fruits list through this for loop
}
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...