
The JavaScript code consists of 10 lines of code. Line 1: const calculateTotal equals function open parenthesis price comma quantity comma tax close parenthesis open curly brace at indentation level 0. Line 2: StartCommand let EndCommand subtotal equals price asterisk quantity semicolon at indentation level 1. Line 3: return subtotal plus tax open parenthesis subtotal close parenthesis semicolon. Line 4: Close curly brace semicolon at indentation level 0. Line 5: const calcTax equals function open parenthesis subtotal close parenthesis open curly brace at indentation level 0. Line 6: StartCommand let EndCommand taxRate equals 0.05 semicolon at indentation level 1. Line 7: StartCommand let EndCommand tax equals subtotal asterisk taxRate semicolon at indentation level 1. Line 8: return tax semicolon at indentation level 1. Line 9: close curly brace semicolon at indentation level 0. Line 10: StartCommand let EndCommand temp equals calculateTotal open parenthesis 50 comma 2 comma calcTax close parenthesis semicolon at indentation level 0. calculateTotal in line 1 corresponds to calculateTotal in line 10. tax in line 1 corresponds to calcTax in line 10 and is labeled 1 Passing the calcTax open parenthesis close parenthesis function object as a parameter. Note: We can say that calcTax variable here is a callback function. Tax in line 3 corresponds to calcTax in line 5 and is labeled 2 The local parameter variable tax is a reference to the calcTax open parenthesis close parenthesis function.
Back