Before anything a taste, my name is Brian and I am from Argentina. It's the first time I ask on this site, I really did not know him and he seems to be very good haha.
I tell you ... I have a small project of a game in JS that is based on turn-based combat against an AI that I am programming.
Now, I need to bring from a file called "clases.js" just the classes like my AI and my player, each with their main statistics.
export class humano {
constructor() {
this.hp = 500
this.hpv = this.hp
this.atk = 13 }
atacar(who){
who.hpv=who.hpv - this.atk } };
Now to that class I want to call it from my 'index.js' which is the main file where I do all the actions.
import humano from 'clases.js';
let jorge = new humano;
console.log(jorge);
I want to believe that this is how a class is imported or what is not from another file?
The error that the Chrome console gives me is:
Uncaught SyntaxError: Unexpected token export
I hope you can give me a hand, the idea with this project is to be able to learn Javascript better, I am relatively new in what is programming but I am practicing every day feeling more fluent, but if I do not ask I do not advance :) thank you very much and I hope you have formulated the question well.
Edit! Maybe I should use Babel ... I do not understand it well .. you will say.