-1
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

为什么?

4

3 回答 3

3

财产的价值lenght将是undefined

undefined - 1NaN

你拼错了length

于 2013-09-11T15:28:55.333 回答
1

的拼写length错误?我认为它会显示编译错误。

于 2013-09-11T15:29:44.507 回答
-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;
}
于 2013-09-11T15:51:19.950 回答