Nalini1998 / Project_Public

MIT License
2 stars 0 forks source link

Write a function, greetAliens(), that takes in an array of strings and uses a for loop to print a greeting with each string in the array. #577

Closed Nalini1998 closed 1 year ago

Nalini1998 commented 1 year ago

The greeting should take the following format: “Oh powerful [stringElement], we humans offer our unconditional surrender!”

const greetAliens = arr => {
  for (let i = 0; i < arr.length; i++) {
    console.log(`Oh powerful ${arr[i]}, we humans offer our unconditional surrender!`); 
  }
}
const arr = ["Blorgous", "Glamyx", "Wegord", "SpaceKing"];
greetAliens(arr);
Nalini1998 commented 1 year ago

Output:

Oh powerful Blorgous, we humans offer our unconditional surrender!
Oh powerful Glamyx, we humans offer our unconditional surrender!
Oh powerful Wegord, we humans offer our unconditional surrender!
Oh powerful SpaceKing, we humans offer our unconditional surrender!