myContact = [
{
name: 'John',
lastName: 'Doe',
phone: 123456789
},
{
name: 'Mark',
lastName: 'Doe',
phone: 98765432
}
]
On click event, add a condition to check the array length, if the length > 2.
onClick() {
if(myContact.length > 2)
redirect page...
return false; // don't want the code to continue executing
}
error: Typescript type boolean is not assignable to void
I try something similar using some(), the below my conditions works as required
let checkValue = myContact.some(s => s.name === 'John')
if(checkValue)return false
But if I try similar with my contact, E.G
let checkLength = myContact.filter(obj => obj.name).length
if(checkValue)return false // error: error: Typescript type boolean is not assignable to void
How can I fix this issue,
return;voidas it's return type. As such you can't return anything. Though this is speculation as you only provide chunks of code without their context.