function updateRequest(request, { text, mark }, getUser, Request, r, avg, { requestType, requestField }) {
// console.log(params);
const car = new getCar();
console.log('1 ', request[`num_${requestField}`]);
console.log('2 ', requestField[0].toUpperCase());
console.log('3 ', request[requestType]);
console.log('4 ', {[requestField] : text});
console.log('5 ', request.main());
return new Promise((resolve, reject) => {
if ('name' in car) {
resolve(car);
} else {
reject(new Error('Error in value: no name key in object'));
}
});
}
const request = {
id: '002',
main: function(){
return this.id;
},
ReviewOwner : 'Igor',
ReviewCustomer: 'Alex',
mark_owner: '1',
num_owner: '2'
};
const text = 'Message';
const mark = 5;
const getUser = function(){
return {
name: 'Igor',
age: 15
};
};
const getCar = function(){
return {
// name: 'Maseratti',
year: 2015
};
};
const Request = function(){
return {};
};
const r = {};
const avg = 5;
const requestType = 'ReviewOwner';
const requestField = 'owner';
try{
updateRequest(request, { text, mark }, getUser, Request, r, avg, { requestType, requestField })
.then( data => {
console.log(data.name);
});
} catch(e){
console.log(e);
}
function mail({ id, params = {} }){
console.log(params);
}
mail({id: 1});
const data = {
one: {
first: 'first',
second: 'second'
},
two: {
third: 'third',
quattro: 'quattro'
}
};
let {one: {first}} = data ;
console.log(first);