FSD Lab Program-14
FSD Lab Program-14
cd voting-app
Inside the src folder, replace App.js with the following code:
import './App.css';
function App() {
};
return (
<div className="voting-app">
<h2>Voting Application</h2>
<div className="candidates">
{Object.keys(votes).map((candidate) => (
<h3>{candidate}</h3>
<p>Votes: {votes[candidate]}</p>
</div>
))}
</div>
</div>
);
.voting-app {
width: 300px;
text-align: center;
padding: 20px;
border-radius: 10px;
background-color: #f4f4f4;
.candidates {
display: flex;
flex-direction: column;
gap: 15px;
.candidate {
padding: 10px;
border-radius: 5px;
background-color: #fff;
button {
font-size: 16px;
cursor: pointer;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
button:hover {
background-color: #45a049;
Explanation:
o When a user clicks a button, the vote count increases for that candidate.
npm start
3. Click on the "Vote" button for any candidate and watch the votes update in real-
time.