For a school project, I am trying to make a website that does stuff. To make it, I am using HTML, JavaScript, and CSS. I am using a compiler that gives debug hints. These hints are provided from JSLint. I am told that I should combine two of the variables that I have written, but I do not understand what this means.
I have done some research (on Stack Overflow and other websites), but all of these come up with people wanting to put variables into arrays.
Would anybody kindly explain to me what I should do?
The code (simplified):
var x = document.getElementById("some id");
var y = document.getElementById("some other id");
var z = document.getElementsByTagName("some tag name");
And JSLint says:
"Combine this with the previous 'var' statement: var y = document.getElementById("some other id");" and:
Combine this with the previous 'var' statement. var z = document.getElementsByTagName("some tag name");
Important Note: The code does work, but JSLint is telling me to fix it.
var x = document.getElementById("some id"),
y = document.getElementById("some other id"),
z = document.getElementsByTagName("some tag name");
You can declare variables like in the example above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With