我有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);