问题描述:

I cannot figure out why JSlint is giving the following warnings:

  1. Unexpected 'this'
  2. Expected ';' and instead saw 'capWord'
  3. Expected ';' and instead saw 'i'
  4. Stopping

Here is the code : It runs without any errors. I just want to make it JSLint compliant.

"use strict";

function capWord(inStr) {

this.inStr = inStr; //Unexpected 'this'

}

capWord.firstIndex = function(inStr) {

document.write(this.upper(inStr[0])); //Unexpected 'this'

this.space(inStr); //Unexpected 'this'

}

capWord.space = function(inStr) {

for(var i=1;i<inStr.length;i=i+1) { //Unexpected 'for'; Expected ';' and instead saw 'i'

document.write(inStr[i]);

if (inStr[i] == " ") {

document.write(this.upper(inStr[i+1]));

i = i+1;

}

}

}

capWord.upper = function(charUpper) {

return charUpper.toUpperCase();

}

capWord.firstIndex("lfadjadjfkaru wish this wouldnt be hapeingig");

相关阅读:
Top