Codecademy Forums

Formating in Javascript

I’m going through the Javascript course and keep getting errors for things I am not sure if it’s the console in CodeCademy or my code. For example, I wrote this:

let athleteFinalPosition = 'first place';
switch (athleteFinalPosition) {
  case 'first place':
    console.log('You get the gold medal');
    break;
  case 'second place':
    console.log('You get the silver medal!');
    break;
  case 'third place':
    console.log('You get the bronze medal!');
    break;
  default:
    console.log('Invalid item');
    break;
}

But was told it was wrong. When I finally gave up and look up the solution, the only difference I notice is the break line at the beginning. Would my code not work if it doesn’t have that break or is the CodeCademy console thing being a little strict?

let athleteFinalPosition = 'first place';

switch (athleteFinalPosition) {
  case 'first place':
    console.log('You get the gold medal');
    break;
  case 'second place':
    console.log('You get the silver medal!');
    break;
  case 'third place':
    console.log('You get the bronze medal!');
    break;
  default:
    console.log('Invalid item');
    break;
}

Thanks!

Hello, and welcome to the forums :slightly_smiling_face:!

When I ran it in a code editor, I got no errors. I think the goal is to teach syntax at the same time. I looked hard also, and saw no differences exempt for that one line spacing.

I hope this helps =)

3 Likes