Question 24 (Bus Ride) problems

Hey guys, I need some help here please.

I’m not sure how to make a formula for the amount of people that are left over, that don’t fit on the bus. How do you work that out using “if - else” and “greater than” or “less than” functions?

Essentially i’m stuck: I need a formula to work out how to calculate the amount that the bus fills up that’s larger than 30 (it needs to return ANY number larger than 30, not just “2” as the given. Getting the console to return “2 must walk” is easy if you cheat). But I want it to calculate any number I input for stops 1, 2 and 3, and then calculate the excess amount of people who don’t fit on the bus.

This is my current code but it doesn’t work (obviously). The code in line 41 is wrong, I know it, but how do I calculate the overflow?

Hi @Marcelle,

Can you please paste the code here in code format, since it’s difficult for us to write that many lines of code directly from a screenshot?

I see there are many syntax issues in your code. Before console logging, you are applying curly braces which are not needed. This is not a function body to wrap curly braces for.

Incorrect –

var stop2 = parseInt(text); {
console.log("the bus has" + stop2 + "passengers");
}

Correct

var stop2 = parseInt(text); 
console.log("the bus has" + stop2 + "passengers");

There are other “conditional” issues in your code, I would advise you to redo the javascript conditions (if, if-else etc) video to create a strong understanding of how it works.

Happy Learning! :smile:

1 Like