Advertisement
Guest User

Untitled

a guest
Dec 17th, 2022
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react';
  2. import ReactDOM from 'react-dom/client';
  3.  
  4. let data = [
  5.   {name: 'Aron', score: 39},
  6.   {name: 'Kyle', score: 45},
  7.   {name: 'Alex', score: 60},
  8.   {name: 'Chris', score: 95},
  9.   {name: 'Emily', score: 90},
  10.   {name: 'Anna', score: 95},
  11.   {name: 'Kristi', score: 100}
  12. ];
  13.  
  14. function getGrade (score) {
  15.   if (score > 95)
  16.     return 'A+';
  17.   else if (score > 90)
  18.     return 'A';
  19.   else if (score > 80)
  20.     return 'B';
  21.   else if (score > 60)
  22.     return 'C';
  23.   else if (score > 40)
  24.     return 'D';
  25.   else
  26.     return 'F';
  27. }
  28.  
  29. // write code below this line
  30. function Grades(props) {
  31.   return (
  32.     <ul>
  33.     {data.map (student => (
  34.         <li>{student.name} - {getGrade(student.score)}</li>
  35.     ))}
  36.     </ul>
  37.   );
  38. }
  39. // write code above this line
  40.  
  41. const root = ReactDOM.createRoot(document.getElementById('root'));
  42.  
  43. // modify code below this line
  44. root.render(<Grades />);
  45. // modify code above this line
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement