perun22
1
I am not sure why the $ sign doesn’t get printed. I can’t pass test 5, so not sure how to fix it.
function instrumentCards
(instrumentCategory) {
const filteredInstruments = instrumentsArr.filter(obj => {
if (obj.category === instrumentCategory) {
return obj.category;
} else if (instrumentCategory === "all")
return instrumentsArr;
})
filteredInstruments.map((card) => {
return `
<div class="card">
<h2>${card.instrument}</h2>
<p>$${card.price}</p>
</div>
`;
});
return filteredInstruments;
};
selectContainer.addEventListener("change", () => {
console.log(instrumentCards(selectContainer.value));
});
dhess
2
Please post a link to the challenge you are working on. Thank you.
dhess
4
That links to the JavaScript curriculum. Please post a link to the specific challenge step you are working on.
Sorry about that, I thought I did it properly. Hope this works
Music Instrument Filter - step 11
dhess
6
Did the instructions ask you to do this?
No, my bad. But the code still doesn’t work even if I remove that portion. I still can’t pass test 5.
dhess
8
Please post your updated code, as follows:
When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add the backticks.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
function instrumentCards(instrumentCategory) {
const filteredInstruments = instrumentsArr.filter(obj => {
if (obj.category === instrumentCategory) {
return obj.category;
} else if (instrumentCategory === "all")
return instrumentsArr;
});
return filteredInstruments;
};
selectContainer.addEventListener("change", () => {
console.log(instrumentCards(selectContainer.value));
});
dhess
10
I don’t see anything wrong with your log, but does it make sense to include this else in your filter?
Array.prototype.filter() - JavaScript | MDN
system
Closed
12
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.