Assignment inside filter

Take your time, follow the code and check your understanding.

The codeArrays
const available = phones.filter(phone => phone.inStock = true);
Your answer3 min · no timer
What needs fixing?

Show solution and explanation

Use phone.inStock or phone.inStock === true. Assignment changes every record and evaluates to true.

The callback assigns true instead of testing stock.