function getNucleobaseCount (strand) {
/*
Returns occurences of nucleobases A and C respectively
*/
var countA = (strand.split("A").lenght - 1);
var countC = (strand.split("C").lenght - 1);
return countA + " " + countC;
}
但是
> console.log(getNucleobaseCount("AAGCATT"))
Nan Nan
而不是预期的3 1
为什么?
答案 0 :(得分:3)
lenght
属性的值为undefined
。
undefined - 1
是NaN
你拼错了length
。
答案 1 :(得分:1)
length
的拼写错误?我认为它会显示编译错误。
答案 2 :(得分:-2)
function getNucleobaseCount (strand) {
/*
Returns occurences of nucleobases A and C respectively
*/
var countA = (strand.split("A").length - 1);
var countC = (strand.split("C").length - 1);
return countA + " " + countC;
}