简体   繁体   中英

No output in Visual Studio Code

I'm learning JavaScript and I wrote a simple program in Visual Studio Code but there was no output what so ever when I attempted to run it.

class main{
    multiplier(x,y){
        return x*y
    }
    main(){
        let x,y
        x = window.prompt('Your favourite number')
        y = window.prompt('Your age')
        console.log(multiplier(x,y))
    }
}

You did several issues

  • didn't create an instance
  • didn't run main()
  • forgot a this

 class main{ multiplier(x,y){ return x*y } main(){ let [x, y] = [0, 0] x = prompt('Your favourite number') y = prompt('Your age') console.log(this.multiplier(x,y)) } } const obj = new main() obj.main()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM