Spread takes all the items in the specified iterables (arrays, objects etc) and copies it.
const indoorActivities = ['Table Tennis', 'Carrom', 'Chess', 'Gym'];
const outdoorActivities = ['Swimming Pool', 'Badminton Court', 'Tennis Court'];
const clubFacilites = [...indoorActivities, 'Squash Court', ...outdoorActivities];
console.log(`indoorActivities : ${indoorActivities}`);
console.log(`outdoorActivities : ${outdoorActivities}`);
console.log(`clubFacilites : ${clubFacilites}`);
When you do not know the number of arguments that will be passed in a function you can use Rest operator.
function calculateFines(baseFee, countyFee, tax = 0.18, ...fines) {
console.log(baseFee, countyFee, tax = 0.18, fines);
return fines.map(fine => baseFee + countyFee + tax + fine);
}
const totalFines = calculateFines(400, 0, .05, 24, 100, 76);
console.log(totalFines);
Peace ✌️