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

129
Views
javascript function returning function instead of float/object

i have a function where im returning some html element, before i return it, if i console.log() it it outputs the numerical value eg. 1234... however its typeof() is "object" even though i have parseFloated() it... after returning it, it returns as a typeof() as function... im trying to pass the return value through to another function, can someone please explain to me what is going wrong? how do i keep the return value as an object or float rather then a function so i can then pass it?

async function checkPrice(page) {
    await page.reload();
    await page.waitForNavigation();
    await page.waitForTimeout(2000); // network idle2 not working... this is sufficient

    var html = await page.evaluate(() => {
        const buyTag = document.querySelectorAll(".MuiButton-root.MuiButton-contained.MuiButton-containedPrimary.MuiButton-sizeMedium.MuiButton-containedSizeMedium.MuiButton-disableElevation.MuiButtonBase-root.color-tertiary.css-k5syhx .css-gmuwbf");

        let prices = [];

        buyTag.forEach((tag) => {  

            if(tag.innerHTML[0] === '$' ) {
                var string = tag.innerHTML;
                var float  = parseFloat(string.replace(/[^0-9.-]+/g, ''));
                if(prices.length < 1) {
                   prices.push(float)
            }}
        });
        return prices
    });
    // console.log(html) returns 1234, typeof() is obj here
    return html
}
// console.log(html) returns a function here
async function priceUpdate(html) { 

    let new_price = []; 
    let old_price = [];

    if(new_price.length < 1) {
        new_price.push(html);
    }
    if(new_price.length > 0) {
        old_price.pop();
        old_price.push(new_price);
        new_price.pop();
        new_price.push(html);
    }
    if(parseFloat(new_price[0]) != 
    parseFloat(old_price[0])) {
        console.log('lowest price changed from: $' + old_price + ' to: ' + '$ ' + new_price);
    }
    else {
        console.log('current price: $' + old_price);
    };
}

async function monitor() {
    let page = await configureBrowser();
    for(var i=0; i=1000; i++) {
        await checkPrice(page);
        await priceUpdate(html);
    }}

monitor()
about 4 years ago · Juan Pablo Isaza
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!