I have this array:
var json = [
{
"id": 1,
"firstName": "Paul",
"lastName": "Carr",
"company": "Foo"
},
{
"id": 2,
"firstName": "Mary",
"lastName": "Menan",
"company": "Foo"
},
{
"id": 3,
"firstName": "Donal",
"lastName": "Carr",
"company": "Bar"
}
];
and this checkbox code:
<div>
<input type="checkbox" id="checkbox" checked={isChecked} onChange={checkHandler} />
<p>{isChecked ? json.map(j => <div>{j.id}, {j.firstName}, {j.lastName}, {j.company}</div>) : json.map(k => {
if(k.company !== "Bar") {
<div>{k.id}, {k.firstName}, {k.lastName}, {k.company}</div>
}
})}</p>
</div>
)
If the box is checked I want the entire array printed. If not, only the people who are not in company Foo should be printed. However, when I run the code I get:
src/App.js
Line 44:111: Array.prototype.map() expects a value to be returned at the end of arrow function array-callback-return
My code works but I’m not sure how I fix it so I don’t get the lint warning. What should it look like?