Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
Rewriting Python Classes to JavaScript

I have some python classes written and being constructed like this:

class Customer:
def __init__(self, name, full_name, gender, age, instruments, paid):
    self.name = name
    self.full_name = full_name
    self.gender= gender
    self.age= age
    self.instruments= instruments
    self.paid= paid

list = []

list.append( Customer('Customer1', 'First Customer', 'Male', 26, ["Guitar", "Bass"], [100, 200]))
list.append( Customer('Customer2', 'Second Customer', 'Female', 24, ["Drums", "Bass"], [150, 230]))

I'm trying to rewrite my functions from python to JavaScript, and having some problems/doubts about this data structure.

The instruments and paid values(only example here) can be text values or numbers. When I access it and select "Customer 1" I should be able to choose the instrument to print the paid price

How do I write the same structure in JavaScript?

All this is that I am trying to change this personal python file to a customer local .html page.

Maybe JavaScript is not the best here and, since i am not proficient on that, I can spent some time in other language to handle it.

How would I write it in .js or, what would be the better option to go with local .html

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you glance at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes

you could end up with

class Customer {
  constructor(name, full_name, gender, age, instruments, paid) {
    this.name = name
    this.full_name = full_name
    this.gender = gender
    this.age = age
    this.instruments = instruments
    this.paid = paid
  }
}
list = []

list.push(new Customer('Customer1', 'First Customer', 'Male', 26, ["Guitar", "Bass"], [100, 200]))
list.push(new Customer('Customer2', 'Second Customer', 'Female', 24, ["Drums", "Bass"], [150, 230]))
console.log(list)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda