I'm getting the following errors from JSLint, and I can't understand them:
-All questions have been answered-
Any help on any of these?
use /*jslint browser: true, devel: true */
function submit() {
"use strict";
document.forms.form.submit();
var Mathematics = document.personal.Mathematics;
var OMathematics = document.personal.OMathematics;
var Sci = document.personal.Sci;
var OSci = document.personal.OSci;
var ELA = document.personal.ELA;
var OELA = document.personal.OELA;
var SS = document.personal.SS;
var OSS = document.personal.OSS;
var Elec1 = document.personal.Elec1;
var OElec1 = document.personal.OElec1;
var Elec2 = document.personal.Elec2;
var OElec2 = document.personal.OElec2;
var Elec3 = document.personal.Elec3;
var OElec3 = document.personal.OElec3;
var Owed = 0;
function calc(n, o) {
if (n >= 90) {
Owed = Owed + 1;
if (n >= 95) {
Owed = Owed + 1;
}
}
else if (o >= 80) {
Owed = Owed + 0.5;
}
if (n > o) {
Owed = Owed + 0.5;
}
if (n < o) {
if (n > 95) {
Owed = Owed - 0.25;
}
}
}
calc(Mathematics, OMathematics);
calc(Sci, OSci);
calc(ELA, OELA);
calc(SS, OSS);
calc(Elec1, Elec1);
calc(Elec2, Elec2);
calc(Elec3, Elec3);
alert(Owed);
}
Here is the code in context: http://jsfiddle.net/Aidoboy/AdzwC/
exceptions being used: "many var statements per function" and "messy white space"
'
document
' was used before it was defined
You get this because the document
variable has not been declared. You can tell JSLint that it should assume the code will run in a browser and therefore assume that things like document
and window
are pre-defined. You can do so with a JSLint comment at the top of your file:
/*jslint browser: true */
['form']
is better written in dot notation
Since you know the name of the property, there is no need to use square bracket notation:
document.forms.form.submit();
'
alert
' was used before it was defined
You can use the devel
option to prevent this error (you also use it to allow, for example, console.log
calls):
/*jslint browser: true, devel: true */
Unexpected
''
There is some invisible character after the closing brace. Just delete that character to remove this error.