I almost have finished my random quote generator but I have a problem, the twitter button open twitter but appear in blank (whitout quote), I have tried solutions of previous post but dont work…and I dont know where is the problem
I changed a couple things with your code. I am a beginner myself by the way, am no expert I thing the main problem with your code was that var currentQuote didn’t have a value, it was an empty string. And that the function to open the tweet was outside of the newQuote function’s scope.
var quotesArr = ["Life is 10% what happens to you and 90% how you react to it. -Charles R. Swindoll",
"Always do your best. What you plant now, you will harvest later. -Og Mandino",
"The past cannot be changed. The future is yet in your power. -Unknown",
"It does not matter how slowly you go as long as you do not stop. -Confucius",
"Keep your eyes on the stars, and your feet on the ground. -Theodore Roosevelt",
"When something is important enough, you do it even if the odds are not in your favor. -Elon Musk",
"He who sows the wind shall reap the whirlwind -Arthur Bomber Harris",
"It's OK to have your eggs in one basket as long as you control what happens to that basket. -H. G. Wells",
"Knowing is not enough; we must apply. Willing is not enough; we must do. -Johann Wolfgang von Goethe",
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it. -Terry Pratchett",
"Real stupidity beats artificial intelligence every time. -Terry Pratchett",
"Sometimes it is better to light a flamethrower than curse the darkness -Terry Pratchett",
"The pen is mightier than the sword if the sword is very short, and the pen is very sharp. -Terry Pratchett",
"Some humans would do anything to see if it was possible to do it. If you put a large switch in some cave somewhere, with a sign on it saying 'End-of-the-World Switch. PLEASE DO NOT TOUCH', the paint wouldn't even have time to dry. -Terry Pratchett",
"The entire universe has been neatly divided into things to a mate with, b eat, c run away from, and d rocks. -Terry Pratchett",
"Evil begins when you begin to treat people as things. -Terry Pratchett",
"It is well known that a vital ingredient of success is not knowing that what you're attempting can't be done. -Terry Pratchett",
"Taxation is just a sophisticated way of demanding money with menaces. -Terry Pratchett",
"Most of the great triumphs and tragedies of history are caused not by people being fundamentally good or fundamentally evil, but by people being fundamentally people -Terry Pratchett."];
var randomQuote;
var currentQuote;
function newQuote() {
randomQuote = Math.floor(Math.random() * (quotesArr.length));
currentQuote = quotesArr[randomQuote];
document.getElementById("Quotes").innerHTML = quotesArr[randomQuote];
$("#tweet").click(function() {
window.open('https://twitter.com/intent/tweet?&text=' + currentQuote);
});
};
Thnanks a lot for you response and you time reviewing my code . You was right I had a empty string . Now the twitter button works almost perfect (when I click one time in the button the web browser open about nine windows) , I am working on that but without your help I would be stuck in the button function.