You have an object containing user data and need to create an array of strings containing user details in a "key: value" format. Which loop might be most suitable for this task?

  • for...in loop
  • for...of loop
  • while loop
  • forEach() method
The for...of loop is most suitable for iterating over object properties when you want to create an array of strings. It directly iterates over iterable values like arrays and works well for this task by extracting key-value pairs from the object.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *