You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/stretch/till.js
+25-3Lines changed: 25 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -22,10 +22,32 @@ const till = {
22
22
};
23
23
consttotalAmount=totalTill(till);
24
24
25
-
// a) What is the target output when totalTill is called with the till object
25
+
// a) What is the target output when totalTill is called with the till object >> "£4.40"
26
26
27
-
// b) Why do we need to use Object.entries inside the for...of loop in this function?
27
+
// b) Why do we need to use Object.entries inside the for...of loop in this function? >> To iterate over both the keys (coin types) and values (quantities) of the till object.
28
28
29
-
// c) What does coin * quantity evaluate to inside the for...of loop?
29
+
// c) What does coin * quantity evaluate to inside the for...of loop? >> It evaluates to NaN because coin is a string (e.g., "1p") and cannot be directly multiplied by a number (quantity).
30
30
31
31
// d) Write a test for this function to check it works and then fix the implementation of totalTill
0 commit comments