Junior — Senior
Moving a random car from the dealership to the garage by pressing a button
livecode
Task condition
It is necessary to modify the existing webpage so that when clicking the "Buy Car" button, a random model from the list of available cars is selected and added to the garage list.
import "./styles.css";
import { List } from "./list";
const listData = [{ label: "Mercedes" }];
const cars = [
"Audi",
"Toyota",
"Lexus",
"Volkswagen",
"Porsche",
"Nissan",
"Hyundai",
"KIA",
"Chevrolet",
"Ford",
"Renault",
"Mazda",
"Suzuki",
];
export default function App() {
return (
<div className="App">
<span>Clicking the "Buy" button will select a random car and add it to the garage</span>
<div>Car dealership: {cars.join(", ")}</div>
<button>Buy Car</button>
<List items={listData} />
</div>
);
}