I am in the process of seperating my code so it is more clean. I have started doing this by putting my functions in their respective module. So instead of keeping it in the "index.js", I am keeping it in "change.js" (example name). Here is my function:
let number = 5;
function change(){
number = number + 1;
}
The problem is, when I put this function in its own respective module called "change.js", when it is called, it gives the error that the variable "number" is not declared. If I then declare it in the "change.js" file, the variable "number" only changes in that file and not in "index.js". Is there anyway to change it in both files, or transfer the value from "change.js" to "index.js"?
Before I proceed to my answer this is how I exported and imported:
I found something that would make it work:
This would then change the variable "number" in the index.js with the function "change" running from module "change.js"!
Your change.js file should look something like this:
And then, on your index.js you can import the variable as
discount tadalafil – purchase tadalafil buy real tadalafil online
propecia amazon – http://propechl.com/ propecia dosage
Mwwoar – US viagra sales viagra soft cheap price