Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda