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

164
Views
How to separate price from an array in JavaScript

Application In PDF/JavaScript

I am trying to print the dollar values only from the array. Tried the following and I am not sure If I am using the correction functions or not.

var pdts = ['Apple*Fruits-$58.9', 'Orange*Fruits-$60.5'];
var arr = pdts.toString().split('-');

console.log(arr[2]);
console.log(arr);

Current Output:

$60.5

Expected output in different lines:

$58.9
$60.5

Please help

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

0

You need to loop over the array, not convert the array to a single string.

var pdts = ['Apple*Fruits-$58.9','Orange*Fruits-$60.5'];

result = pdts.map(pdt => pdt.split('-')[1]).join('\n');
console.log(result);

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!