Skip to content

How to display more than one list element with different values from multiple arrays? #750

Discussion options

You must be logged in to vote

Hi Jess,

Thank you for your feedback, it helped us and we can delete some code lines which is always nice ✌️
We adjusted your code a little bit, because we don't need the slice, so the code looks like this

  return (
    <StyledUnorderedList>
      {dates.map((date, index) => (
        <StyledListItem key={date}>
          {dates[index]}
          <br /> Temperature: {temperatures[index]}
          {temperature_unit}
          <br /> Ø UV-Index: {uv_index[index]}
          <br />Ø Precipitation probability:
          {precProp[index]}
          {precProbUnit}
        </StyledListItem>
      ))}
    </StyledUnorderedList>
  );

Why don't we need the slice? Because we can adjust the number …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@JessicaLoers
Comment options

@TobiasSteinhagen
Comment options

Answer selected by TobiasSteinhagen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants