HomeInterview QuestionsHow do you print the array ['Ram', 'John', 'Sara']…

How do you print the array ['Ram', 'John', 'Sara'] in React?

🟢 Easy Coding Junior level
1Times asked
Apr 2026Last seen
Apr 2026First seen

💡 Model Answer

In React you can render an array by mapping over it and returning JSX for each element. For example: const names = ['Ram', 'John', 'Sara']; return (<ul>{names.map((name, index) => <li key={index}>{name}</li>)}</ul>); This will produce an unordered list with each name as a list item. The key prop helps React identify elements for efficient re-rendering. If you prefer a stateless functional component, you can write: const NameList = ({names}) => (<ul>{names.map((n,i)=> <li key={i}>{n}</li>)}</ul>); Then use <NameList names={names} />. Complexity is O(n) time and O(1) additional space aside from the output.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.

Get Assisting AI — Starts at ₹500