Iterating array uppercasing

const people = ["Scooby", "Velma", "Daphne", "Shaggy", "Fred"]; 
for (let i=0 ;i<people.length ;i++){
    console.log(i.toUpperCase());
}

The code has no problem without the uppercasing, but when i place toUppercase (method), Javascript has a problem with it, and i don’t understand why …
Thanks

You need to UpperCase the value itself and not it’s Index:

  const people = ["Scooby", "Velma", "Daphne", "Shaggy", "Fred"]; 
  for (let i=0 ;i<people.length ;i++){
      console.log(people[i].toUpperCase());
}

thanks, i was looking a long time for it, and it was confusing to me )

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.