Skip to content

Instantly share code, notes, and snippets.

@jonsamp
Last active October 21, 2017 02:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsamp/28823ef8b791de8538d875012776ac05 to your computer and use it in GitHub Desktop.
Save jonsamp/28823ef8b791de8538d875012776ac05 to your computer and use it in GitHub Desktop.
JavaScript Tips Tab: generateTip III
// Tip Limit counter
var tipLimit = 3;
// Generate a number
function generateNumber() {
...
}
// Generate a tip:
// 1. Get random number from generateNumber()
// 2. Use the random number to get the tip from the array
// 3. Show the tip
function generateTip() {
var tip = tipsList[generateNumber()];
var tipElement = document.querySelector('.js-tip');
var tipLimitCount = document.querySelector('.tip-limit-count');
tipElement.innerHTML = tip;
tipLimitCount.innerHTML = tipLimit;
}
...
// Get the first tip
generateTip();
@St1ng2411
Copy link

Good :D!

@WassimaG
Copy link

I wrote everything properly but nothing appears when I re-open the html file on chrome. It's like all my changes on java file aren't connected to the html despite the source file being on the html file. Can you help please?

@hasanfares
Copy link

Did you unzip the folder when you download it

@ArielNuni
Copy link

WassimaG, did you save the changes in the text editor?

@dbrowntastic
Copy link

I'm stuck too, why are the answers from the earlier steps not translating to this?

@krazii-chik
Copy link

me too, have double checked all my entries and can't find the problem. And yes, I have unzipped the file and I have saved the file in my text editor (Atom)

@cziem
Copy link

cziem commented Oct 21, 2017

I had the same challenge... but I noticed the page displayed correctly on firefox developer edition... because I used es6 let to declare the variables, so I changed them to var and the page displayed on chrome...

so you might wanna try tweaking your file a bit to see what works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment