Fcc Random Quote Machine

Hey guys, here is my random quote machine. Feedback will be appreciated thanks. Cheers!!

Congratulations on finishing your quote machine, great work!
I find it hard to read your text with a font like that, but maybe that’s just me.
I see you have a tweet button in your code, but it’s not showing up… Maybe look into that!

Good luck with your next project!


Thanks for the feedback, will work on the tweet button. Cheers!!!

For some reason I thought that one of the user stories was if the tweet is longer than 140 characters, reduce the length and add “…” at the end. In any case, I think that that would be a nice touch for user interaction. Or if it fits in the tweet, add the author’s name.

Honestly I’m just nitpicking to give you something to practice with because your Random Quote design and execution is great. It’s responsive and well done!

Thanks for the feedback, will definitely work on the tweet issue. cheers!!

Good for practicing writing algorithms, but thinking about UX, it’s unlikely the user would want the quotes truncated in a “dumb” way. That way you’d often lose the main point of the quote. It’d be better to let the user trim the quote as they see fit (e.g. removing non-content words like “the”).

Even better, you could have a more elegant solution that:

  • Generates a permalink to that quote displayed on your page using a query string (going to the URL with that query string would display that specific quote rather than a random one)
  • Shortens the URL+query string with a URL shortening API. I’m not sure what’s available in this regard; it’s possible you can do it with Twitter’s own URL shortener
  • Gets the length of the author’s name
  • Adds some syntactical padding before the author’s name (e.g. ellipsis … for truncation plus an em dash —)
  • Subtracts the length of authors name + padding + shortened URL from 140 and truncates the quote to that length
  • Puts all of that info in the Twitter URL string, ready to post

I think all of this should be doable without a back end. Might try making a proof of concept later.

1 Like

Ah-haaaa! That sounds even better and something I’d like to try myself, thanks! :slight_smile:

OK, added the functionality to my random quote generator. It works! With one caveat: I wasn’t able to find a URL shortener API that doesn’t require an API key (which you’d need a back end to keep hidden).

It turned out it wasn’t a problem, though: Twitter automatically treats all URLs as 23 characters when calculating tweet lengths, then converts them to https://t.co/ links when you send the tweet.

I was originally gonna write up my findings on here, but in the end it turned into a whole blog post.