We provided a function for each task from 1 to 5, solve the tasks inside the functions.
Task1: Write an if condition to check if a variable age is greater than or equal to 18. If true, log "You are eligible for voting," otherwise, log "You are not eligible for voting."
Task2: Use a while loop to print numbers from 1 to 5.
Task3: Use a for loop to print even numbers from 2 to 10.
Task4: Implement a switch statement to determine the day of the week based on a numeric input (1 for Sunday, 2 for Monday, etc.).
Task5: Write a function named sum that takes two parameters (num1 and num2) and returns their sum.
Task6: Create an array of fruits and use array methods to log each fruit to the console.