Lost trying to use switch statements

I am lost I am trying to use switch statements, I thought when ever we use switch statements we need to use break after every case? I use break it doesn’t work.

Here is my code.
function calculateWeight(earthWeight, planet) {
switch (planet){
case ‘Mercury’:
earthWeight * 0.378;
break;
case ‘Venus’:
earthWeight * 0.907;
break;
case ‘Mars’:
earthWeight * 0.377;
break;
case ‘Jupiter’:
earthWeight * 2.36;
break;
case ‘Saturn’:
earthWeight * 0.916;
break;
default:
return ‘Invalid Planet Entry. Try: Mercury, Venus, Mars, Jupiter, or Saturn.’
break;
}
}
I had to get rid of break, to each case: Then it worked just fine.

Remember that want to return the new weight from this function, not just calculate it. How can you fix your code?

1 Like