Javascript数组问题数组内部的ParseInt字符串

我有7天在所有论坛中进行搜索。很难,也许这种情况很特殊:(非常感谢您的帮助...)

    const ARRAY1 = [



      { Ville:  'Anse-bertrand (97121)',taux: 0.6393  },{ Ville: 'Saint-Louis (97421)',taux: 0.6359  },{ Ville:  'La Haute-Beaume (05140)',taux:    0.5900  },{ Ville:  'Fontanès-de-Sault (11140)',taux:  0.5791  },{ Ville:  'Chambord (41250)',taux:   0.5658  }


    ]


    const ARRAY2 = (ARRAY1.Ville.replace(/\d/g,""))
    //i want to replace all characteres of all (Ville) by "_". To just have the postal codes.

    var KeySearched = "05140"



    function isTaux (answer) {
      return answer.Ville ==KeySearched ;
    }

    console.log(ARRAY2.find(isTaux).taux);
zl1002007 回答:Javascript数组问题数组内部的ParseInt字符串

您想要这样的东西吗?

const ARRAY2 = [
  { Ville:  'Anse-Bertrand (97121)',taux: 0.6393  },{ Ville: 'Saint-Louis (97421)',taux: 0.6359  },{ Ville:  'La Haute-Beaume (05140)',taux:    0.5900  },{ Ville:  'Fontanès-de-Sault (11140)',taux:  0.5791  },{ Ville:  'Chambord (41250)',taux:   0.5658  }
]


const NewArr = ARRAY2.map(function(a,b) {
    a.Ville = a.Ville.replace(/[\D]/g,"")
    return a
})

console.log(NewArr)

本文链接:https://www.f2er.com/2353388.html

大家都在问