[Solved] Check if value of one array is found in another [closed]


You can simlpy cycle through the second array, split at :, check the first part and, in case of a match, return the second

function findX(value, arr) {
  for (var i = 0; i < arr.length; i++) {
    var toSplit = arr[i].split(':');
    if (toSplit[0] === value) {
      return toSplit[1];
     }
  }
}

console.log(findX("User1-2", ["User1-2:280", "User2-2:280", "User3-2:280", "User4-2:280"]));

5

solved Check if value of one array is found in another [closed]