I am trying to sort an array by 'version' and then identify all string that begin with 'iPad'.
The following code does not log anything and returns an error.
orderedUsers: function () {
let newarray = sortBy(this.jobs, 'version').reverse()
for (let i in newarray) {
if (i.version.startsWith('iPad')) {
console.log(i.version);
}
}
return newarray
error:
TypeError: Cannot read property 'startsWith' of undefined
If I remove the for-loop and just put:
orderedUsers: function () {
let newarray = sortBy(this.jobs, 'version').reverse()
return newarray
The list is correctly sorted by version. This makes me think the error is related to how I have written my for-loop or if statement.
What am I doing wrong here.