Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

select random quotes from array called anecdotes

    <div className="app">
      <h1>Anecdote of the day</h1>
      <p>{anecdotes[selected]}</p>
      <button
        onClick={() =>
          setSelected(Math.floor(Math.random() * anecdotes.length))
        }
      >
        Next anecdote
      </button>
    </div>
 
PREVIOUS NEXT
Tagged: #select #random #quotes #array #called #anecdotes
ADD COMMENT
Topic
Name
1+3 =