创建一个名为isIsogram的函数,该函数接受一个参数,一个单词用于测试它是否为等值线图。这个函数应该返回一个布尔值来指示它是一个isogram(true)还是not(false)。这里是相应的代码:函数中的for循环不正确
function isIsogram(word){
if (typeof word !== 'string'){
return 'Argument should be a string';
}
if (word === ' '){
return false;
}
else{
for(var i=0; i<word.toLowerCase().length; i++){
if (word.charAt(i)>1){
return false;
}
else{
return true;
}
}
}
}
console.log(isIsogram('Akosombo'));
'Akosombo'应该返回false,但它返回true。
https://ericlippert.com/2014/03/05/how-to-debug-small-programs/ – David