Missing semi-colon error

I am an advanced beginner transitioning into Java and am running into a very simple but very annoying error. I have included it below.

SyntaxError: unknown: Missing semicolon. (2:5)

  1 | function multiplesOf3and5(number) {
> 2 |   int a=5;
    |      ^
  3 |   return true;
  4 | }
  5 |

Are you working on Java or Javascript? They are different and your syntax matches neither, as far as I can tell.

Java, I am able to use this syntax on my local computer but when I copy the code into the ide I run into this kind of error. I included a simplified version of the error.

Which IDE are you copying this into?

I could be wrong, but I haven’t seen Java use the function keyword.

The freecodecamp ide, for solving the interview prep questions.

FreeCodeCamp uses Javascript. It is a completely different language from Java.

int is not a keyboard in Javascript. Variables are not declared with types in Javascript.

Functions in Java work completely differently than the syntax you wrote:

1 Like

If you want to do interview prep with java then leetcode would be the way to go.

Ok i am not familiar with javascript and thought it was java based on the small amount of code that is visible on the screens.

Nope. Very, very different languages. If you want to learn JavaScript, this is a good place to start. If you want to learn Java, our infrastructure doesn’t support that.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.