10. Global Vs Local Variables



var my_number = 7;

var timesTwo = function(number) {
my_number = number * 2;
console.log("Inside the function my_number is: ");

console.log("Outside the function my_number is: ");

It keeps saying to me, "Oops, try again. Make sure you used the 'var' keyword inside the function!"

Someone please help!


Well for one you need VAR my_number right under var timesTwo and I just ran your code through with the change and it passes so happy coding! :smiley:


Hi, @bibleman13. I tried doing as you suggested. I have to sadly say, it did not work. Please could you post the right code here for me. As well as the reasons as to why there are differences in the code I set an you set!:innocent: I would much appreciate it.




Dear @bibleman13,

I am very sorry about the last post. It turns out all I needed to do was refresh the page, and ta da! It worked!

I am grateful for all of your help.




No problem man! I hate when that happens. You think nothing is working and bam it works! xD Glad to help!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.