JavaScript Assignment No. 07 (Loops)

In this seventh JavaScript assignment, I focused on mastering loops in JavaScript. I worked with different types of loops, such as `for`, `while`, and `do-while`, to iterate through arrays and perform repetitive tasks efficiently. This assignment enhanced my understanding of how loops can automate processes and significantly reduce code redundancy.

Task 1. Loop Through Fruits Array and Log Each Element.

Fruits: ["apple", "banana", "cherry"]

Output:

Task 2. Add Color Names to Paragraph Using Loop and QuerySelector.

Colors: ["red", "green", "blue"]

Output:

Task 3. Print Numbers from 1 to 10 Using a For Loop.

Numbers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Output:

Task 4. Print Numbers from 5 to 1 Using a While Loop.

Output:

Task 5. Display Names Array in a Div Using a Loop.

Names: ["Ali", "Sara", "Ahmed"]

Output:

Task 6. Change Paragraph Text to "Loading..." Using QuerySelector.

Output: Status

Task 7. Calculate and Display Array Sum Using a Loop.

Numbers: [5, 10, 15]

Output:

Task 8. Join and Display City Names Using a Loop.

Cities: ["Karachi", "Lahore", "Quetta"]

Output:

Task 9. Print Even Numbers from 1 to 20 Using a Loop.

Output:

Task 10. Find and Display Largest Number in Array Using a Loop.

Cities: [45, 22, 89, 100]

Output:

Task 11. Change Div Text to "Task Complete" Using QuerySelector.

Output: Status

Task 12. Calculate and Display Average Temperature Using a Loop.

Temperatures: [30, 35, 32, 40]

Output:

Task 13. Sum All Numbers from 1 to 100 and Display the Result.

Numbers: 1 to 100

Output:

Task 14. Print All Animal Names in a Single Paragraph Using Loop.

Animals: ["dog", "cat", "bird"]

Output:

Task 15. Change Heading Text to "Welcome to JavaScript!" Using QuerySelector.

Output: Status

Task 16. Print Multiples of 5 Between 1 and 50 Using a Loop.

Output:

Task 17. Count Scores Above 75 in an Array Using a Loop.

Numbers: [80, 60, 90, 70]

Output:

Task 18. Change Text to "Updated Successfully" Using QuerySelector.

Output: Status

Task 19. Display Subjects List in a Paragraph Using a Loop.

Fruits: ["Math", "Science", "English"]

Output: