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

93
Views
I have an array which I need to extract only number

var price = [ Rs 299, Rs 499, Rs 899, Rs 199 ];

I need to store this [ 299, 499, 899, 199] in an array.

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

If your array elements are strings this should work

let array = [ 'Rs 299', 'Rs 499', 'Rs 899', 'Rs 199' ]
console.log(array.map(elem => Number(elem.split(' ')[1])))

about 4 years ago · Santiago Gelvez Report

0

We can use string match() here for a regex based solution:

var array = ["Rs 299", "Rs 499", "Rs 899", "Rs 199"];
var nums = array.map(x => Number(x.match(/\d+(?:\.\d+)?/)[0]));
console.log(nums);

about 4 years ago · Santiago Gelvez 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!