E
E
Elena2020-12-04 13:43:32
React
Elena, 2020-12-04 13:43:32

How to make a function that will accept a faq card and the second argument is a string that needs to be searched through the search?

Tell me how to write a function through the search that takes 2 parameters - the faq card and the string on which to search, and then you need to see if the string in the title matches or matches the description, and if it matches, then you need to return true, and if it does not match, return false. Thank you in advance.
Here is the code:

return (
    <div>
      <div className={classes.root}>
        <GridContainer>
          <GridRow>
            <GridColumn>
              <header className={classes.headerSearch}>
                <GridColumn>
                  <div className={classes.mainHeading}>
                    Какую информацию вы хотите найти?
                  </div>
                </GridColumn>
                <GridColumn size={10} offset={1}>
                  <Input
                    type="text"
                    placeholder="Найдите всё, что требуется(онлайн-консультация,
                    добавление записи в медкарту...)"
                    fullWidth
                    classes={{
                      inputWrapper: classes.searchField,
                    }}
                    startAdornment={
                      <InputAdornment
                        position="start"
                        classes={{ root: classes.searchImg }}
                      >
                        <Search></Search>
                      </InputAdornment>
                    }
                  />
                </GridColumn>
              </header>
            </GridColumn>
          </GridRow>
          <GridRow>
            {currentFaqs.map((card) => {
              return (
                <GridColumn size={switchDeviceSize}>
                  <Link to={`/faq/${card.id}`} className={classes.cardLink}>
                    <div className={classes.blockCard} key={card.id}>
                      <div className={classes.boxTitle}>
                        <p className={classes.titleSection}>{card.title}</p>
                        <p className={classes.textSection}>{card.description}</p>
                      </div>
                    </div>
                  </Link>
                </GridColumn>
              );
            })}
          </GridRow>
        </GridContainer>
      </div>
    </div>
  );
};

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question