I have an array like this
array: [
'Student 1|##|100|@@|Third answer',
'Student 2|##|10|@@|Third Answer ',
'Student 10|##|50|@@|Third Answer'
]
In it 100 represents the id of the first item of the array, 10 represents the id of the second item of the array and 50 is the id of the third item and so on.
I also have a variable whose value is equal to the id which can be 100 or 10 or 50.
var id = data.myId
I need to check if the id exists in the array.
So if the id is 10 and I do array.includes(id.toString())
it won't return true unless my array is like:
array: [
'Student 1|##|100|@@|Third answer',
'Student 2|##|10|@@|Third Answer ',
'Student 10|##|50|@@|Third Answer',
'10'
]
So how do I do that. I am guessing I have to use regex.