Loop through an object using the map in React



const subject = {
    name: 'Math',
    score: 98,
    sub_code: 'M01',
    teacher_name: 'Ramanujam',
};

return (
    <div>
        {Object.keys(subject).map(key => (
            <div key={key}>
                {key}: {subject[key]}
            </div>
        ))}
    </div>
);

Leave a comment