1

I am making a website using HTML5 Javascript and Django 1.8 , Python 3.5 and I am getting the following error

Uncaught SyntaxError: Unexpected identifier

class User {
  constructor(nothing) {
    //doNothing
  }

  function myFunction(p1, p2) {
    return p1 * p2; // The function returns the product of p1 and p2
  }


  function afunc() {
    var mydata = "kk";

    return (mydata);
  }
}
var abc = new User();
var kk = abc.myFunction(1, 2);
console.log(kk);

EDIT

Is there any debugger for Javascript in Pycharm latest version(2018) like we have a debugger for Java in netbeans we can add breakpoints see values of variables etc

Cœur
  • 37,241
  • 25
  • 195
  • 267
dddar
  • 27
  • 2
  • 9

1 Answers1

2

remove the function from the class methods. class methods don`t use function declarations as its methods.

class User {
    constructor(nothing){
        //doNothing
    }
    myFunction(p1, p2) {
        return p1 * p2;
    }

    afunc() {
        var mydata="kk";

        return (mydata);
    }
}
var abc=new User();
var kk=abc.myFunction(1,2);
console.log(kk);
zabusa
  • 2,520
  • 21
  • 25
  • Question edited if u answer it I will accept your anser – dddar Feb 16 '18 at 17:33
  • 1) [Pycharm Professional - JS debugging](https://www.jetbrains.com/help/pycharm/debugging-javascript-in-chrome.html) 2) I think you could also use a [@classmethod](https://stackoverflow.com/a/12179752/9155312) decorator. – wrabbit Feb 16 '18 at 17:47
  • Also I would like to mention that you should limit your questions to the scope of the original question. If zabusa's answer did resolve your question please accept. – wrabbit Feb 16 '18 at 18:11
  • @dddar change to `vscode` dont use `pycharm` for javascript.dont mess python with javascript – zabusa Feb 16 '18 at 18:22