Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!