Hi folks,
I’ve hit a bit of a brick wall with my random code generator: http://codepen.io/l3w15/pen/qRYPpG
I’m reasonably happy with it except that the way I’ve set up my newQuote() function in js means that you get a new font-awesome twitter bird in the button every time you generate a new quote. (The one furthest right tweets the newest quote, as you go left they hold the link for previous quotes). The relevant bit of javascript is:
var tweet = document.getElementById(‘tweet’);
var link = document.createElement(‘a’);
link.setAttribute(‘href’, ‘https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=’ + a);
link.setAttribute(‘target’, ‘_blank’);
var birdie = document.createElement(‘i’);
birdie.setAttribute(‘class’, “fa fa-twitter”);
birdie.setAttribute(‘aria-hidden’, ‘true’);
tweet.appendChild(link);
link.appendChild(birdie);
As this function runs onload and onclick, I understand why it generates a new bird icon each time, but can’t seem to fix it… thought it should be possible to use replaceChild, but am getting frustrated after many failed attempts.
Any help greatly appreciated