#Im having trouble with Javascript classes, i cant find my problem online

21 messages · Page 1 of 1 (latest)

round glade
#

Long story short im coding a Enigma machine for a school project. I made a Class that simulates the Rotors for it and when I make multiple objects using the class they all use the last created objects values

#

This works correctly ^

#

It returns this as it should, the first line is just the Rotors wiring and the alphabet for reference

#

How ever if i uncomment this line:

tiny bobcat
#

JS doesn't have self, it's this

round glade
#

Even though im calling the forward function on rotor_1 its returning stuff from rotor_2

#

ah

tiny bobcat
#

Impatient JS (in #faq) if you know another programming language

#

also, you can forget var exists

round glade
#

Oh wow that fixed the problem

tiny bobcat
#

We have const, and let if you need reassignment

tiny bobcat
round glade
#

Yeah

#

Im following a python tutorial, just translating to javascript

tiny bobcat
#

Don't.

round glade
#

Not the greatest idea, but the guy explains it the easiest way i understand it

tiny bobcat
#

well I guess your class project is to be given in a short period, but yeah

#

If you know another programming language, Impatient JS to learn. If you don't, js.info (another resource in #faq)

round glade
#

Its all full year project, im just now getting around to it