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

141
Views
JavaScript choosing a specific type of number in a list

I'm trying to choose specific type of number among a list of numbers in JavaScript. a Console.log(vars) outputs the list of numbers below. And I need to choose the numbers that have the 0.000 format, meaning at least one number before decimal and three after the decimal point.

(66) ['47,416.00', '0.001', '08:17:36', '47,416.00', '0.005', '08:17:36', '47,416.00', '0.088', '08:17:36', '47,416.00', '0.003', '08:17:35', '47,416.00', '0.214', '08:17:33', '47,416.00', '0.005', '08:17:33', '47,416.00', '0.008', '08:17:33', '47,416.00', '0.005', '08:17:33', '47,416.00', '0.010', '08:17:33', '47,416.00', '0.758', '08:17:33', '47,416.00', '', '0.134', '08:17:33', '47,416.50', '', '0.004', '08:17:33', '47,416.00', '0.018', '08:17:31', '47,416.00', '0.171', '08:17:30', '47,416.00', '0.034', '08:17:28', '47,416.00', '', '0.010', '08:17:28', '47,416.50', '0.003', '08:17:28', '47,416.50', '1.000', '08:17:28', '47,416.50', '0.011', '08:17:28', '47,416.50', '0.001', '08:17:25', '47,416.50', '0.005', '08:17:25']

I tried a regex and you can see it in my code below but regex is only returning true.

var tradescards = [];
let regex = /\d\.\d\d\d/;


function obser1() {
    const trades = document.querySelector("#root > main > div.main-left > div.react-grid-layout > div:nth-child(3) > div > div.by-card__body > div > div");
    const vars = [...trades.querySelectorAll("span")].map(span => span.textContent);
    const observer = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
            if (mutation.addedNodes.length) {
                console.log(regex.test(vars));
            }
        })
    });
    observer.observe(trades, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true
    })
}
window.setTimeout(obser1, 1900);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

arr.filter(e => /\d.*\.\d\d\d\b/g.test(e))

You are looking for something like this.

There's a post explaining working of Regex.

Regex Matches - Wildcard then one decimal place

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!