function createNewProduct(ns, division) {
    let wantToSpend = 2e9; // $2b minimum.
    let spent = 0;
    let spentOnProducts = [];
    try {
        spentOnProducts = division.products
            .map((p) => budgetFromProductName(p))
            .sort((a, b) => a - b)
            .reverse();
    } catch (error) {}
    if (spentOnProducts.length > 0) {
        // If our products weren't named correctly default to assuming they were 2b, 4b, 8b...
        wantToSpend = wantToSpend * Math.pow(2, spentOnProducts.length - 1);
        wantToSpend = Math.max(spentOnProducts[0] * 2, wantToSpend, myCorporation.revenue * 100);
    }
    let productname = `${division.type}-${Math.log10(wantToSpend).toFixed(2)}`;
    try {
        ns.corporation.makeProduct(division.name, hqCity, productname, wantToSpend / 2, wantToSpend / 2);
        log(ns, `SUCCESS: Starting development of new product '${productname}' for ${mf(wantToSpend)}.`, 'info', true);
        spent += wantToSpend;
        extraReserve = 0;
    } catch (e) {
        // If we fail to create the product, just reserve the money we want to spend.
        log(ns, `  Reserving budget of ${mf(wantToSpend)} for next product.`);
        extraReserve = wantToSpend;
    }
    return spent;
}
/**
 * Try to create a new product for this division, with a budget at least twice the size of the last
 * one we bought. If we don't have enough money, or all our product slots are full,
 * then set a reserve for the desired amount.
 *
 * @param {NS} ns
 * @param {Division} division
 * @returns amount of money spent, if any.
 */
Try to create a new product for this division, with a budget at least twice the size of the last
one we bought. If we don't have enough money, or all our product slots are full,
then set a reserve for the desired amount.

@param {NS} ns
@param {Division} division
@returns amount of money spent, if any.
Try to create a new product for this division with a budget at least twice the size of the last one we bought . If we don ' t have enough money or all our product slots are full then set a reserve for the desired amount . @param { NS } ns @param { Division } division @returns amount of money spent if any .
function createNewProduct(ns, division) {
    let wantToSpend = 2e9; 
    let spent = 0;
    let spentOnProducts = [];
    try {
        spentOnProducts = division.products
            .map((p) => budgetFromProductName(p))
            .sort((a, b) => a - b)
            .reverse();
    } catch (error) {}
    if (spentOnProducts.length > 0) {
        wantToSpend = wantToSpend * Math.pow(2, spentOnProducts.length - 1);
        wantToSpend = Math.max(spentOnProducts[0] * 2, wantToSpend, myCorporation.revenue * 100);
    }
    let productname = `${division.type}-${Math.log10(wantToSpend).toFixed(2)}`;
    try {
        ns.corporation.makeProduct(division.name, hqCity, productname, wantToSpend / 2, wantToSpend / 2);
        log(ns, `SUCCESS: Starting development of new product '${productname}' for ${mf(wantToSpend)}.`, 'info', true);
        spent += wantToSpend;
        extraReserve = 0;
    } catch (e) {
        log(ns, `  Reserving budget of ${mf(wantToSpend)} for next product.`);
        extraReserve = wantToSpend;
    }
    return spent;
}
function createNewProduct ( ns , division ) { let wantToSpend = 2e9 ; let spent = 0 ; let spentOnProducts = [ ] ; try { spentOnProducts = division . products . map ( ( p ) => budgetFromProductName ( p ) ) . sort ( ( a , b ) => a - b ) . reverse ( ) ; } catch ( error ) { } if ( spentOnProducts . length > 0 ) { wantToSpend = wantToSpend * Math . pow ( 2 , spentOnProducts . length - 1 ) ; wantToSpend = Math . max ( spentOnProducts [ 0 ] * 2 , wantToSpend , myCorporation . revenue * 100 ) ; } let productname = ` ${ division . type } ${ Math . log10 ( wantToSpend ) . toFixed ( 2 ) } ` ; try { ns . corporation . makeProduct ( division . name , hqCity , productname , wantToSpend / 2 , wantToSpend / 2 ) ; log ( ns , ` ${ productname } ${ mf ( wantToSpend ) } ` , 'info' , true ) ; spent += wantToSpend ; extraReserve = 0 ; } catch ( e ) { log ( ns , ` ${ mf ( wantToSpend ) } ` ) ; extraReserve = wantToSpend ; } return spent ; }
Try to create a new product for this division, with a budget at least twice the size of the last
 one we bought.
Try to create a new product for this division with a budget at least twice the size of the last one we bought .
// $2b minimum.
 // If our products weren't named correctly default to assuming they were 2b, 4b, 8b...
 // If we fail to create the product, just reserve the money we want to spend.
