.length来查找String值的长度。 "Alan Peter".length; // 10例如,如果我们创建了一个变量var firstName = "Charles" ,我们可以通过使用firstName.length属性找出字符串"Charles"长度。 .length属性计算lastName变量中的字符数,并将其分配给lastNameLength 。 lastNameLength应该等于8。
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), "lastNameLength should be equal to eight.");'
- text: 您应该使用.length来获取lastName的长度,如下所示: lastName.length 。
testString: 'assert((function(){if(code.match(/\.length/gi) && code.match(/\.length/gi).length >= 2 && code.match(/var lastNameLength \= 0;/gi) && code.match(/var lastNameLength \= 0;/gi).length >= 1){return true;}else{return false;}})(), "You should be getting the length of lastName by using .length like this: lastName.length.");'
```