-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ45.js
20 lines (20 loc) · 813 Bytes
/
Q45.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"use strict";
// 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, modelName, ...options) {
const car = {
manufacturer,
modelName,
};
for (const option of options) {
Object.assign(car, option);
}
return car;
}
const carInfo = createCar('Ford', 'Raptor', { color: 'black', year: 2023, feature: ["transmission", "automatic"] });
console.log(carInfo);