Build a Music Instrument Filter

what am I getting wrong here

Build a Music Instrument Filter

Please post your code. Thanks

function instrumentCards(instrumentCategory) {
  const instruments =
    instrumentCategory.toLowerCase() === "all"
      ? instrumentsArr
      : instrumentsArr.filter(
          ({ category }) => category.toLowerCase() === instrumentCategory.toLowerCase()
        );
  return instruments
    .map(({ instrument, price }) => {
      return `<div class="card">
            <h2>${instrument}</h2>
            <p>$${price}</p>
          </div>
        `})
        .join("")
}

I’ve edited your post to improve the readability of the code. 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 instruments =
    instrumentCategory.toLowerCase() === "all"
      ? instrumentsArr
      : instrumentsArr.filter(
          ({ category }) => category.toLowerCase() === instrumentCategory.toLowerCase()
        );
  return instruments
    .map(({ instrument, price }) => {
      return `<div class="card">
            <h2>${instrument}</h2>
            <p>$${price}</p>
          </div>
        `})
        .join("")
}

what is the difference

function instrumentCards(instrumentCategory) {
  const instruments =
    instrumentCategory.toLowerCase() === "all"
      ? instrumentsArr
      : instrumentsArr.filter(
          ({ category }) => category.toLowerCase() === instrumentCategory.toLowerCase()
        );
  return instruments
    .map(({ instrument, price }) => {
      return `<div class="card">
            <h2>${instrument}</h2>
            <p>$${price}</p>
          </div>
        `})
        .join("")
}

error i am getting : 1. You should join the array returned by the
instrumentCards
function. Do not modify your event listener.

You provided a link to the challenge rather than a link to the specific step in the challenge you need help with. I’m assuming you’re on step 14.

Please reset this step and try again since you have changed the seed code. (Please pay attention to your data. Do the values in the select dropdown need to be converted to lower case?)

Only add what is asked to complete this challenge.

here

function instrumentCards(instrumentCategory) {
  const instruments =
    instrumentCategory.toLowerCase() === "all"
      ? instrumentsArr
      : instrumentsArr.filter(
          ({ category }) => category.toLowerCase() === instrumentCategory.toLowerCase()
        );
  return instruments
    .map(({ instrument, price }) => {
      return `<div class="card">
            <h2>${instrument}</h2>
            <p>$${price}</p>
          </div>
        `})
        .join("")
}

That looks like the exact same code (that you’ve posted 4x now?). Did you make any changes based upon what was said?

I have not seen any reply based on the code i posted

You should go back and read this.

still not parsed

function instrumentCards(instrumentCategory) {
  const instruments =
    instrumentCategory === "all"
      ? instrumentsArr
      : instrumentsArr.filter(
          ({ category }) => category === instrumentCategory
        );
  return instruments
    .map(({ instrument, price }) => {
      return `<div class="card">
            <h2>${instrument}</h2>
            <p>$${price}</p>
          </div>
        `})
        .join("")
}

I’ve edited your post to improve the readability of the code. 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 (').

You still made changes to the starting code other than the one requested change. I would reset the step, make absolutely zero extra changes, and only add the 1 requested change.

Fixed, thank you very much.

1 Like