You should use the % operator

Hello,

I have a problem with this task. In the screenshot you can see it.

image

Waht’s wrong? Any ideas?

Thanks

Can you share the question?

I’ve got it

There was a missing ;

1 Like

That could be the reason. But semicolon is not that important in javascript though. :slight_smile:

Not exactly true.

http://jsfiddle.net/zZcUx/1/

I agree. However, if instructions occupy lines of their own then you don’t need a semi-colon.
Try:
var number = 0
var name = “Sam”
This will work.
However, if you have both instructions on the same line, you would need to add a semi-colon to separate them as follows:
var number = 0; var name = “Sam”
If you don’t, you will see an error.

I agree. However, if instructions occupy lines of their own then you don’t need a semi-colon.

Not exactly true.

    var cars = ['bmw', 'corvette', 'porche'];
    var x = 3
    [...cars].forEach((car) => console.log(car));

// error
2 Likes

Oh I actually didn’t know that. Thanks for sharing.:smile:
It means it is safer to use a semi-colon after every instruction.

Yes, semicolons usually don’t matter in JS. Yes, there are some specific edge cases where it does make a difference. There are large debates for and against. I’ve worked for people that would hit me over the head if I used semicolons and my current employer insists on them. That is a debate for another time and place.

It looks to me that it’s just a problem with the test:

assert(/\\s+?remainder\\s*?=\\s*?.*%.*;/.test(code), 'You should use the <code>%</code> operator');

It doesn’t look like it’s made to handle the possibility of leaving off the semicolon, it expects it to be there.

Remember that FCC is made by volunteers so things get put together somewhat ramshackle sometimes. I don’t know if FCC has an official policy on semicolons. I think it’s just that some guy/gal put together this test that way.

1 Like