Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js destructuring

function calculatefood (food, tip) {
    tip_percent = tip / 100;
    tip_amount = food * tip_percent;
    total = food + tip_amount;
    return [tip_amount, total];
}
const [tip, sum] = calculatefood(100, 20);
console.log(tip);
console.log(sum);
Source by dmitripavlutin.com #
 
PREVIOUS NEXT
Tagged: #js #destructuring
ADD COMMENT
Topic
Name
3+6 =