-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path09_objectCloneAssign.js
35 lines (29 loc) · 1.36 KB
/
09_objectCloneAssign.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const bankSBI = {
name : "State Bank of India",
branch : "Akluj",
IFSC : "SBIN0000305"
}
const bankLocation = {
city : "Akluj",
dist : "Solapur",
pin : 413101
}
console.log('1. Create the object -> bankSBI with literals.');
console.log('2. Create the object -> bankLocation with properties city, dist, pin.');
console.log(`3. Clone bankSBI & bankLocation object using 'Object.assign()' method and log.`);
const objectClone = Object.assign({}, bankSBI, bankLocation);
console.table(objectClone);
const rateOfInterest = {
homeLoanInterest : 8.40,
personalLoanInterest : 11.15,
dueInterest : 10
}
console.log('4. Create the object -> rateOfInterest with properties homeLoanInterest, personalLoanInterest, dueInterest.');
console.log(`5. Merge bankSBI, bankLocation & rateOfInterest in new Object and log.`);
const sbiDetails = Object.assign({}, bankSBI, bankLocation, rateOfInterest);
console.table(sbiDetails);
process.stdout.write('-> ');
process.stdout.write(' ');
console.log(`The ${sbiDetails.name}(${sbiDetails.IFSC}), city-${sbiDetails.city}, dist-${sbiDetails.dist}, pin-${sbiDetails.pin}`);
process.stdout.write(' ');
console.log(`The ${sbiDetails.name} offers Interest rate of ${sbiDetails.homeLoanInterest}% on Home Loan and ${sbiDetails.personalLoanInterest}% on Personal Loan with upto ${sbiDetails.dueInterest} years of Due Interest.`);