From 93311eeb1d1a2ff2f4305df91e55cfc0b1722e39 Mon Sep 17 00:00:00 2001 From: Benjamin Bandla Khonye <82065910+Bandla1995@users.noreply.github.com> Date: Wed, 2 Feb 2022 10:57:28 +0200 Subject: [PATCH] refactored the multiple arguments I used one argument , to a function that needs multiple pieces of data. --- dirty-control-structures.js | 44 +++++++++---------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/dirty-control-structures.js b/dirty-control-structures.js index 3545df5..107d897 100644 --- a/dirty-control-structures.js +++ b/dirty-control-structures.js @@ -1,38 +1,14 @@ -main(); - -function main() { - const transactions = [ - { - id: 't1', - type: 'PAYMENT', - status: 'OPEN', - method: 'CREDIT_CARD', - amount: '23.99', - }, - { - id: 't2', - type: 'PAYMENT', - status: 'OPEN', - method: 'PAYPAL', - amount: '100.43', - }, - { - id: 't3', - type: 'REFUND', - status: 'OPEN', - method: 'CREDIT_CARD', - amount: '10.99', - }, - { - id: 't4', - type: 'PAYMENT', - status: 'CLOSED', - method: 'PLAN', - amount: '15.99', - }, - ]; - +class User{ + const transactions(userData) = { + this.id = userData.id; + this.type = userData.type; + this.status = userData.status; + this.method = userData.method; + this.amount = userData.amount; + } +} processTransactions(transactions); + } function processTransactions(transactions) {