+ 1

Is there a way to get around a Uncaught Reference Error between 2 functions?

When I declare c1 variable (from function a) and try to pass the result to another function: function s. I want to recall c1 in if/else if statements to produce a result for another variable; s1. JavaScript doesn't remember that c1 has been declared in the 1st function; function a. When I place them both in 1 function they WORK... When I take out ALL if/else if (c1 == x)... statements the s function WORKS. I declared c1 "outside" of the functions; which is global, correct? Even global doesn't work. I haven't tried placing/declaring both functions together yet. I need a way to call c1 (and others) into multiple functions for my AUB program/app to work. Also, I want the same random number to be called. Thank you for any help. https://code.sololearn.com/WL9CoN1b0XKj/?ref=app

23rd May 2018, 1:49 PM
James Pinkerton
James Pinkerton - avatar
2 Antworten
+ 1
Can you show me an example code please?
23rd May 2018, 1:53 PM
Michael55555
Michael55555 - avatar
+ 1
Yes!!! I figured it out...and it's working good now. YAY!!! I was at it for a week (that is a long time to be stumped for me so far). So I broke down and went to W3Schools.com site and tried another way to make a variable global. Now the question is...can I have a few of these global variables in my AUB program/app? Read my comment section in my function "s" in the code...
1st Jun 2018, 2:59 PM
James Pinkerton
James Pinkerton - avatar