Last active
October 21, 2017 02:21
-
-
Save jonsamp/28823ef8b791de8538d875012776ac05 to your computer and use it in GitHub Desktop.
JavaScript Tips Tab: generateTip III
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 tovar
and the page displayed on chrome...so you might wanna try tweaking your file a bit to see what works...