Hello. I am almost finished with the random quote generator challenge. I am unsure of how to tweet the quote that is displayed in the window. What should I consider in clearing this mini-challenge? (Just tips please.) Thank you for the help.
I am able to tweet out new quotes that are not being displayed.
Look at where you’re initializing randomNumber
and think about the scope (or scopes) in which it exists.
Edit:
Hint #2
function getNewRand() {
var a = Math.floor(Math.random() * 10) + 1;
return a;
}
var b;
function getStoredRand() {
if (b === undefined) {
b = Math.floor(Math.random() * 10) + 1;
}
return b;
}
// Sample output
getNewRand(); // 2
getNewRand(); // 7
getNewRand(); // 8
a; // ReferenceError: a is not defined
b; // undefined
getStoredRand(); // 6
b; // 6
getStoredRand(); // 6
getStoredRand(); // 6
getNewRand(); // 5
a; // ReferenceError: a is not defined
b; // 6
1 Like