I've created a custom list with 100 random quotes in the Title field. Now I am trying to adapt some existing code to select a quote at random and display it. I've gotten it to display all quote and print the random quote number to the log. Stuck on displaying only the random quote.

Any help greatly appreciated... Thanks, Martin

screen shot


Looks like you are retrieving all 100 quotes and then randomly picking one. You might want to look at generating the random number and then selecting a single item from the list.

/_api/web/lists/getbytitle('Tasks')/Items?$select=Title&$filter=Id eq 1

Replace the list name and the ID of course.

To stay with your code, and downloading all 100, try something like:

var theQuote = newQuote[rand].Title;

You could also use something like this: https://www.blogger.com/blogger.g?blogID=6074070440029916342#editor/target=post;postID=1999918282449567995;onPublishedMenu=allposts;onClosedMenu=allposts;postNum=0;src=postname

  • That fixed it.... much appreciated! – Martin Mar 29 '18 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.