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

169
Views
Can map function in JS do multiple transformations at once?

I wonder whether a map-function in JavaScript can do more than one transformation to an array at once.

For instance, can the items of an array be transformed to be doubled AND then to be divided by 3?

Thank you

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want to make multiple transformations to an array element at once all you have to do is use parenthesis to separate and have them be done in a certain order.

For your example, you could do it like this:

var array = [1, 2, 3, 4];
array.map(num => (num * 2) / 3);

Which would give you

[0.6666666666666666, 1.3333333333333333, 2, 2.6666666666666665]
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!