Bill Helper explainer

Still got the same message.

1 Like

Take out the line let people = 4, and remove tax from the parameters of the function.

people is the 2nd parameter of the function.

When the function is called like this splitBill(76, 4), people gets the value 4. If you hardcode 4 inside the function like this: let people = 4, then what happens if you call the function with 6 as an argument, like this: splitBill(112, 6)?

Let’s look at a simpler example about parameters and arguments:

function add(num1, num2) { // num1 and num2 are parameters
    return num1 + num2;
}
add(5, 6) // 5 and 6 are arguments

When the code above runs, num1 will store the value 5 and num2 will store the value 6. The function will return 5 + 6, or 11.

Hope that makes sense!
Ben

1 Like

Yup, still not there.

1 Like

Take out total += 76. You are calling the function with 76 as an argument, so total is storing this 76. If you have the line total += 76 inside the function, it will add 76 to any total you call the function with.

1 Like

It worked, you’re the best!

1 Like

I’m trying to run the code but its not working. My internet connection is fine and working without any interruptions. Would anyone have an idea why this may be happening? Has anyone else experienced something similar? Thanks.

1 Like

I’ve tried re-setting the puzzle but it hasn’t worked either.

1 Like

could you post a screenshot of your code?

1 Like

1 Like

I think the issue is not the code. Do you see the circle of doom in the lower right side of the screenshot? Its there even before I begin to type anything. And the code refuses to run. I’m stuck at this stage in the course and would be really grateful for any tips.

1 Like

Hey there, we’ve seen a few bug reports of the same issue, where the webview panels on the right fail to load. However, usually both fail to load, and in your screenshot it looks like the Example Solution webview loaded successfully, which is interesting.

I’ll pass this along to our engineering team. In the meantime, refreshing the page or trying the puzzle in a different browser might solve the problem.

Hope this helps!
Ben

1 Like

how output comes 21.8 ??? i did not get how tax is calculated ?

Hey there, the calculateTax() function is in additional code, and imported into this puzzle. It looks like this:

function calculateTax(total) {
    return total * 0.15;
}

Then, it’s used inside the splitBill() function. It takes the total that is passed into splitBill(), and uses it to calculate the tax, like this:

let tax = calculateTax(total)

Hope this helps!
Ben


Ok people…
To help those that are stuck
Make sure your using the correct function when adding in the calculatorTax function… In " mean different then those not in "
The tax+= total should be a separate demand in the puzzle