Complete the code to define a getter that returns the count of items in the store.
const store = reactive({ items: ['apple', 'banana', 'cherry'] });
const itemCount = computed(() => store.[1].length);The getter accesses the items array in the store to compute its length.
Complete the code to create a computed getter that returns items filtered by a minimum length.
const minLength = 6; const filteredItems = computed(() => store.items.filter(item => item.length [1] minLength));
The getter filters items whose length is greater than or equal to the minimum length.
Fix the error in the computed getter that returns the uppercase version of the first item.
const firstItemUpper = computed(() => store.items[0].[1]());
The correct JavaScript string method to convert to uppercase is toUpperCase().
Fill both blanks to create a getter that returns a map of items with their lengths, filtering only items longer than 5 characters.
const itemLengths = computed(() =>
store.items
.filter(item => item.length [1] 5)
.map(item => ({ [2]: item, length: item.length }))
);The filter uses '>' to select items longer than 5 characters. The map creates objects with the key 'item' holding the item string.
Fill all three blanks to create a getter that returns an object mapping uppercase item names to their index, only for items with length less than 7.
const itemIndexMap = computed(() => {
return store.items
.map(([1], [2]) => ({ name: [1].toUpperCase(), index: [2] }))
.filter(obj => obj.name.length [3] 7)
.reduce((acc, obj) => {
acc[obj.name] = obj.index;
return acc;
}, {});
});The map function uses item and i as parameters. The filter keeps names with length less than 7.