-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path45.ts
23 lines (16 loc) · 907 Bytes
/
45.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//45.Cars: Write a function that stores information about a car in a Object. The function should always receive a manufacturer and a model name. It should then accept an arbitrary number of keyword arguments. Call the function with the required information and two other name-value pairs, such as a color or an optional feature. Print the Object that’s returned to make sure all the information was stored correctly.
function createCar(manufacturer: string, model: string, ... properties: [string, any][]): any
{
const car: any = {
manufacturer: manufacturer,
model: model,
};
for (const [key, value] of properties)
{
car[key] = value;
}
return car;
};
// Example usage:
const myCar = createCar("Toyota", "Land Cruiser", ["color", "Black"], ["Optional Feature", "sunroof"], ["Speed", "180 - 240 KM/H"]);
console.log(myCar);