Tell us what’s happening:
I think the solution that some of the tests want is wrong.
e.g. the solution in Test 2 is “$12.73” but the unrounded price is “12.735” so when I round it, it becomes “12.74” which doesn’t count.
And when I use Math.floor() other tests fail.
Your code so far
const rent = {
"HD": 3.99,
"4K": 5.99
}
const buy = {
"HD": 12.99,
"4K": 19.99
}
function getStreamingBill(cart, subscription) {
let price = 0;
for (const movies of cart){
price += (movies["type"] == "buy") ? buy[movies["format"]] : rent[movies["format"]];
}
switch(subscription){
case "basic":
price = price * 0.9;
break;
case "premium":
price = price * 0.75;
break;
}
return `$${Math.round(price * 100) / 100}`;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0
Challenge Information:
Daily Coding Challenge - Streaming Cost
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-18
GitHub Link: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/curriculum/challenges/english/blocks/daily-coding-challenge/6a15cadf5f240d05a2649556.md
ILM
June 18, 2026, 8:33am
2
I have opened this issue about this, thank you for reporting
opened 08:33AM - 18 Jun 26 UTC
scope: curriculum
status: waiting triage
daily coding challenge
### Describe the Issue
Daily Coding Challenge 312 ("Streaming Cost") has test c… ases whose expected outputs land on a half-cent rounding boundary, so the "correct" answer depends on the rounding method and the order of operations rather than on any well-defined rule. Three of the six tests are affected:
| Test | Inputs | True total | Expected | `Math.round` (round half up) | Sum-then-multiply |
| - | - | - | - | - | - |
| 2 | `[HD rent, HD buy]`, `premium` | 16.98 × 0.75 = **12.735** | `$12.73` | `$12.74` | `$12.73` |
| 4 | `[4K buy, 4K buy]`, `premium` | 39.98 × 0.75 = **29.985** | `$29.98` | `$29.99` | `$29.98` |
| 6 | `[HD rent, 4K rent, HD buy, 4K buy, HD buy]`, `basic` | 55.95 × 0.9 = **50.355** | `$50.36` | `$50.36` | `$50.35` |
Why this happens:
- The description says "rounded to two decimal places", which a learner reasonably implements as round-half-up via `Math.round(price * 100) / 100`. But `16.98 * 0.75` is stored in IEEE-754 as `12.734999999999999432`, so `Math.round(... * 100) / 100` yields `12.74` while the reference solution's `toFixed(2)` (and Python's `f"{:.2f}"`) yields `12.73`. The expected output only matches because the reference solution happens to use `toFixed`, which silently relies on the floating-point representation rather than on a defined rounding rule. The learner's answer is arguably the more mathematically correct one.
- Test 6 is broken even without changing the rounding method: accumulating per item (what the reference solution does) gives `50.355000000000004 → 50.36`, but summing first and then applying the discount, both using `toFixed`/`.2f`, gives `50.355 → 50.35`. Two equally valid implementations of the same approach disagree.
This affects both the JavaScript and the Python versions, which share the same challenge ID and the same expected outputs.
### Affected Page
https://www.freecodecamp.org/learn/daily-coding-challenge/2026-06-18
### Your code
```js
function getStreamingBill(cart, subscription) {
let price = 0;
for (const movies of cart) {
price += (movies["type"] == "buy") ? buy[movies["format"]] : rent[movies["format"]];
}
switch (subscription) {
case "basic":
price = price * 0.9;
break;
case "premium":
price = price * 0.75;
break;
}
return `$${Math.round(price * 100) / 100}`;
}
```
### Expected behavior
The test inputs should be chosen so no total lands on a half-cent boundary (i.e. the third decimal of the discounted total is clearly 0-4 or 6-9), making the expected output independent of the rounding method and the order of operations. The JavaScript and Python versions must be updated in lockstep so they keep the same inputs and expected outputs.
### Screenshots
N/A
### System
- Device: Laptop
- OS: N/A
- Browser: N/A
- Version: N/A
### Additional context
Source files:
- JavaScript: https://github.com/freeCodeCamp/freeCodeCamp/blob/5a0247f95f5cb675a4409f2eb22603e16eaf4401/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/6a15cadf5f240d05a2649556.md#L35-L62
- Python: https://github.com/freeCodeCamp/freeCodeCamp/blob/5a0247f95f5cb675a4409f2eb22603e16eaf4401/curriculum/challenges/english/blocks/daily-coding-challenges-python/6a15cadf5f240d05a2649556.md#L38-L80