Helpers at the Bottom
JavaScript
10 pts
Helpers at the Bottom
The starter has the main program at the top and two helpers at the bottom. It crashes with ReferenceError: Cannot access ‘teaTotal’ before initialization, because the helpers are arrow functions in consts.
Fix it without moving the console.log lines: turn teaTotal and label into function declarations (they stay below). Then the output is:
45 Selam pays 45 Nakfa
Checklist
- Turn both helpers into function declarations.
- Keep the main program (the two
console.loglines) at the top. - The helpers still return the right values.
- The two lines are printed.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
