Compare two string with third-string like JSON Array full name
var source = intentObj.slots.toPlazaName.value.toString(); // Jaipur
var destination = intentObj.slots.fromPlazaName.value.toString(); // Kishangarh
match with this "FullName": "Jaipur - Kishangarh Section",
My response
{
"projectid": 10,
"FullName": "Kishangarh -Ajmer- Beawar",
"piu": "PIU-Ajmer",
"NumberofLanes": "6L",
"NHNo_New": "8",
"NHNo_Old": "8",
"Total_Length": 92,
"state_name": "Rajasthan"
},
{
"projectid": 15,
"FullName": "Reengus - Sikar",
"piu": "PIU-Sikar",
"NumberofLanes": "4L",
"NHNo_New": "52",
"NHNo_Old": "11",
"Total_Length": 44,
"state_name": "Rajasthan"
},
{
"projectid": 20,
"FullName": "Rajsamand - Gangapur - Bhilwara",
"piu": "PIU-Chittorgarh",
"NumberofLanes": "4L",
"NHNo_New": "758",
"NHNo_Old": "76B",
"Total_Length": 87.25,
"state_name": "Rajasthan"
},
my create function
function findSourceDestination(source, destination, callback) {
var matchPlazas = [];
var projectFullName = [];
for (var i = 0; i < nhai_response.GetALexDataInJSONResult.length; i++) {
// console.log(nhai_response.GetALexDataInJSONResult[i]["FullName"]);
if (nhai_response.GetALexDataInJSONResult[i]["FullName"].includes(source)) {
// console.log("source " + nhai_response.GetALexDataInJSONResult[i]["FullName"]);
projectFullName.push(nhai_response.GetALexDataInJSONResult[i]);
}
}
for (var j = 0; j < projectFullName.length; j++) {
if (projectFullName[j]["FullName"].includes(destination)) {
console.log('----------------' +projectFullName[j]["FullName"] + '----------destination '+ destination +'------------');
matchPlazas.push(projectFullName[j]);
}
}
callback(matchPlazas);
}
I have full name string another. I have two another string. I want to match source string with my full name first-word destination will match or contain with full name, not the first string like the source string.
Please help me.