Can't get "unknown" author on a twitter share screen?

Hi guys, I’m almost done with my random quote machine but there is a one small issue that I encountered. When u press “get quote” button for the unknown author and press share via twitter, it will not display unknown author of a particular quote. Other quotes with a specific author are displayed fine. Also how can you separate quote text from the author via JavaScript. Because I want author to be on the text line.

Here is my codepen link:


// result of data search
var quote = "If you come to a fork in the road, take it.";
var author = ""; // You need to add a value here if you are displaying it later

// easy fix
if (!author) author = "- Unknown"

// then it is easy to do the following
$('.author-text').text('said by ' + author); + author + ...));

// bonus tip, use ES6 template strings not the long crap you were doing
// also, \n does nothing on twitter, so you can't really separate it that way`"${quote}" -- ${author}`);
1 Like

Thank You very much. I only need this fix : if (!author) author = “- Unknown”;
and it solved problem :slight_smile:

1 Like