Programming Exercises

Create a dropdown that lets users select a country, and display the selected country below.

Medium

Problem Statement

Create a dropdown that lets users select a country, and display the selected country below.

Sample Input

["India", "USA", "Canada"]

Sample Output

Initially: Selected Country: India
 After selection: Selected Country: [chosen country]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React, { useState } from "react"; const CountrySelector = () => { return ( <div> <select> <option>India</option> <option>USA</option> <option>Canada</option> </select> <p>Selected Country:</p> </div> ); }; export default CountrySelector;
Log in or sign up to run or submit your code.Log inSign up
Input
["India", "USA", "Canada"]
Expected Output
Initially: Selected Country: India
 After selection: Selected Country: [chosen country]