exam.md

md3 kBIn Solution.zip

React Mock Exam - Chapters 01-09

⚠️ IMPORTANT: Before You Start

Add your information as comments at the top of src/App.jsx:

JSX
/*
Student ID: [Your Student ID]
Full Name: [Your Full Name]
*/

You must include this information in your submission. Missing information will result in point deduction.


Instructions

  • Duration: 60 minutes
  • Answer all questions by modifying the provided template
  • Write clean, readable code
  • Follow React best practices
  • All solutions should be implemented in the template files
  • You can create additional component files in the src folder if needed

Question 1: Components (Chapter 4)

Points: 15

In the provided template, create a function component called StudentCard that displays:

  • Student name
  • Student ID
  • Course name

Modify App.jsx to use this component and display at least 2 students in the solutions section.


Question 2: Props (Chapter 5)

Points: 15

Create a Product component that accepts props:

  • name (string)
  • price (number)
  • inStock (boolean)

Display the product information. If the product is out of stock, show a message "Out of Stock".

Add this component to your App.jsx and display at least 2 products (one in stock, one out of stock) in the solutions section.


Question 3: State (Chapter 6)

Points: 15

Create a counter component called Counter that:

  • Has a count state starting at 0
  • Has a button to increment the count
  • Has a button to decrement the count
  • Displays the current count

Add this component to your App.jsx in the solutions section.


Question 4: Hooks - useState (Chapter 7)

Points: 15

Create a component called NameCounter using the useState hook that:

  • Has a state for count starting at 0
  • Has a state for name starting at "Counter"
  • Displays: {name}: {count}
  • Has a button to increment the count
  • Has a button to change the name to "Updated Counter"

Add this component to your App.jsx in the solutions section.


Question 5: Events (Chapter 8)

Points: 15

Create a component called ItemList with:

  • An input field
  • A button labeled "Add"
  • A list that displays all added items
  • When the button is clicked, add the input value to the list and clear the input

Add this component to your App.jsx in the solutions section.


Question 6: Forms (Chapter 9)

Points: 20

Create a registration form component called RegistrationForm with:

  • Name input (text)
  • Email input (email)
  • Password input (password)
  • Submit button
  • Display the form data when submitted (use controlled components)
  • Show the submitted data below the form

Add this component to your App.jsx in the solutions section.


Submission Instructions

  1. Test your solution: Make sure all components work correctly by running npm run dev

  2. Compress your solution:

    • Compress the entire React_Mock_Exam folder (including node_modules folder)
    • Use ZIP format
    • Name the file appropriately (e.g., using your Student ID)
  3. Upload your solution:

    • Upload the compressed file to the URL provided during the exam
    • Make sure the upload completes successfully
    • Keep a copy of your solution until you receive confirmation

Important Notes:

  • Include the node_modules folder in your submission
  • Make sure your Student ID and Full Name are in the comments at the top of src/App.jsx
  • Late submissions will not be accepted

Good Luck! 🍀

In Solution.zip